3 * FusionForge top-level information
5 * Copyright 2002, GForge, LLC
6 * Copyright 2009-2011, Roland Mas
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfcommon.'include/Error.class.php';
26 class FusionForge extends Error {
30 var $software_version ;
33 * FusionForge - FusionForge object constructor
35 function FusionForge() {
38 $pkg = dirname(dirname(__FILE__)).'/pkginfo.inc.php';
39 if (file_exists($pkg)) {
43 if (isset($forge_pkg_name)) {
44 $this->software_name = $forge_pkg_name;
46 $this->software_name = 'FusionForge' ;
49 if (isset($forge_pkg_version)) {
50 $this->software_version = $forge_pkg_version;
52 $this->software_version = '5.2.50' ;
55 if (isset($forge_pkg_type)) {
56 $this->software_type = $forge_pkg_type;
58 $this->software_type = $this->software_name;
64 function getNumberOfPublicHostedProjects() {
65 $res = db_query_params ('SELECT group_id FROM groups WHERE status=$1',
68 $this->setError('Unable to get hosted project count: '.db_error());
72 $ra = RoleAnonymous::getInstance() ;
73 while ($row = db_fetch_array($res)) {
74 if ($ra->hasPermission('project_read', $row['group_id'])) {
81 function getNumberOfHostedProjects() {
82 $res = db_query_params ('SELECT group_id FROM groups WHERE status=$1',
85 $this->setError('Unable to get hosted project count: '.db_error());
89 $ra = RoleAnonymous::getInstance() ;
90 while ($row = db_fetch_array($res)) {
91 if ($ra->hasPermission('project_read', $row['group_id'])) {
98 function getNumberOfActiveUsers() {
99 $res = db_query_params ('SELECT count(*) AS count FROM users WHERE status=$1 and user_id != 100',
101 if (!$res || db_numrows($res) < 1) {
102 $this->setError('Unable to get user count: '.db_error());
105 return $this->parseCount($res);
109 function getPublicProjectNames() {
110 $res = db_query_params ('SELECT unix_group_name, group_id FROM groups WHERE status=$1 ORDER BY unix_group_name',
113 $this->setError('Unable to get list of public projects: '.db_error());
117 $ra = RoleAnonymous::getInstance() ;
118 while ($row = db_fetch_array($res)) {
119 if ($ra->hasPermission('project_read', $row['group_id'])) {
120 $result[] = $row['unix_group_name'];
126 function parseCount($res) {
127 $row_count = db_fetch_array($res);
128 return $row_count['count'];
134 // c-file-style: "bsd"