1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
<?php
/**
* FusionForge top-level information
*
* Copyright 2002, GForge, LLC
* Copyright 2009-2011, Roland Mas
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software
* Foundation; either version 2 of the Licence, or (at your option)
* any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with FusionForge; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once $gfcommon.'include/Error.class.php';
class FusionForge extends Error {
var $software_name ;
var $software_type ;
var $software_version ;
/**
* FusionForge - FusionForge object constructor
*/
function FusionForge() {
$this->Error();
$pkg = dirname(dirname(__FILE__)).'/pkginfo.inc.php';
if (file_exists($pkg)) {
include $pkg;
}
if (isset($forge_pkg_name)) {
$this->software_name = $forge_pkg_name;
} else {
$this->software_name = 'FusionForge' ;
}
if (isset($forge_pkg_version)) {
$this->software_version = $forge_pkg_version;
} else {
$this->software_version = '5.3.2' ;
}
if (isset($forge_pkg_type)) {
$this->software_type = $forge_pkg_type;
} else {
$this->software_type = $this->software_name;
}
return true;
}
function getNumberOfPublicHostedProjects() {
$res = db_query_params ('SELECT group_id FROM groups WHERE status=$1',
array ('A'));
if (!$res) {
$this->setError('Unable to get hosted project count: '.db_error());
return false;
}
$count = 0;
$ra = RoleAnonymous::getInstance() ;
while ($row = db_fetch_array($res)) {
if ($ra->hasPermission('project_read', $row['group_id'])) {
$count++;
}
}
return $count;
}
function getNumberOfHostedProjects() {
$res = db_query_params ('SELECT group_id FROM groups WHERE status=$1',
array ('A'));
if (!$res) {
$this->setError('Unable to get hosted project count: '.db_error());
return false;
}
$count = 0;
$ra = RoleAnonymous::getInstance() ;
while ($row = db_fetch_array($res)) {
if ($ra->hasPermission('project_read', $row['group_id'])) {
$count++;
}
}
return $count;
}
function getNumberOfActiveUsers() {
$res = db_query_params ('SELECT count(*) AS count FROM users WHERE status=$1 and user_id != 100',
array ('A'));
if (!$res || db_numrows($res) < 1) {
$this->setError('Unable to get user count: '.db_error());
return false;
}
return $this->parseCount($res);
}
function getPublicProjectNames() {
$res = db_query_params ('SELECT unix_group_name, group_id FROM groups WHERE status=$1 ORDER BY unix_group_name',
array ('A'));
if (!$res) {
$this->setError('Unable to get list of public projects: '.db_error());
return false;
}
$result = array();
$ra = RoleAnonymous::getInstance() ;
while ($row = db_fetch_array($res)) {
if ($ra->hasPermission('project_read', $row['group_id'])) {
$result[] = $row['unix_group_name'];
}
}
return $result;
}
function parseCount($res) {
$row_count = db_fetch_array($res);
return $row_count['count'];
}
}
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
|