3 * Site Admin page for maintaining groups'databases
6 * - browse aggregate numbers of databases of specific type (active,
8 * - list all databases of given type
9 * - edit some database (by going to group's DB Admin page)
10 * - register existing database in system
12 * Copyright 1999-2001 (c) VA Linux Systems
13 * Copyright 2010 (c) Franck Villaume - Capgemini
15 * This file is part of FusionForge. FusionForge is free software;
16 * you can redistribute it and/or modify it under the terms of the
17 * GNU General Public License as published by the Free Software
18 * Foundation; either version 2 of the Licence, or (at your option)
21 * FusionForge is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 require_once('../env.inc.php');
33 require_once $gfcommon.'include/pre.php';
34 require_once $gfwww.'admin/admin_utils.php';
36 if (!forge_get_config('use_project_database')) {
37 exit_disabled('home');
40 session_require_global_perm ('forge_admin');
42 if (getStringFromRequest('submit')) {
43 $group_id = getIntFromRequest('group_id');
44 $groupname = getStringFromRequest('groupname');
45 $dbname = getStringFromRequest('dbname');
49 $group = group_get_object_by_name($groupname);
50 if (!$group || !is_object($group)) {
52 } elseif ($group->isError()) {
53 exit_error($group->getErrorMessage(),'home');
56 $group_id = $group->getID();
58 $user =& session_get_user();
59 if (!$user || !is_object($user)) {
60 exit_error(_('Could Not Get User'),'home');
61 } elseif ($user->isError()) {
62 exit_error($u->getErrorMessage(),'home');
66 $res = db_query_params ('
67 INSERT INTO prdb_dbs(group_id, dbname, dbusername, dbuserpass, requestdate, dbtype, created_by, state)
68 VALUES ($group_id,$1,$2,$3,$4,1,$5,1)
76 if (!$res || db_affected_rows($res) < 1) {
77 $error_msg .= _('Error Adding Database: ') .db_error();
79 $feedback .= _('Project'). " <em>".$group->getUnixName()."</em>" ._('added already active database');
82 $error_msg .= _('Unable to insert already active database.');
86 site_admin_header(array('title'=>_('Site Admin: Groups\' DB Maintenance')));
88 $res_db = db_query_params ('
89 SELECT stateid,statename,COUNT(*) AS count
90 FROM prdb_dbs,prdb_states
92 GROUP BY statename,stateid
97 echo '<h3>' ._('Statistics for Project Databases').'</h3>';
99 if (db_numrows($res_db) > 0) {
103 $title[]= _('Count');
104 echo $GLOBALS['HTML']->listTableTop($title);
106 while ($row_db = db_fetch_array($res_db)) {
108 print '<tr><td style="text-align:center"><a href="'.getStringFromServer('PHP_SELF').'?displaydb=1&dbstate='.$row_db['stateid'].'">'.$row_db['statename'].'</a></td><td style="text-align:center">'.$row_db['count'].'</td></tr>';
112 echo $GLOBALS['HTML']->listTableBottom();
115 echo '<p>' ._('No databases defined').'</p>';
121 $res_db = db_query_params ('
128 $row_db = db_fetch_array($res_db);
130 print '<hr /><h3>' ._('Displaying Databases of Type:') .$row_db['statename'].' </h3><ul>';
132 $res_db = db_query_params ('
140 while ($row_db = db_fetch_array($res_db)) {
141 print '<li>'.util_make_link ('/project/admin/database.php?group_id='.$row_db['group_id'],$row_db['dbname']).'</li>';
153 <h3><?php echo _('Add an already active database'); ?></h3>
155 <form name="madd" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
160 <td><?php echo _('Project Unix Name:'); ?><?php echo utils_requiredField(); ?></td>
161 <td><input type="text" name="groupname" /></td>
165 <td>Database Name:<?php echo utils_requiredField(); ?></td>
166 <td><input type="text" name="dbname" /></td>
170 <input type="submit" name="submit" value="<?php echo _('Add'); ?>"/>
175 site_admin_footer(array());