3 * Project Admin: Module of common functions
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * Copyright 2011, Franck Villaume - Capgemini
8 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org/
11 * This file is part of FusionForge.
13 * FusionForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with FusionForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 Standard header to be used on all /project/admin/* pages
32 function project_admin_header($params) {
33 global $group_id,$feedback,$HTML;
35 $params['toptab']='admin';
36 $params['group']=$group_id;
38 session_require_perm ('project_admin', $group_id) ;
40 $project = group_get_object($group_id);
41 if (!$project || !is_object($project)) {
48 $labels[] = _('Project Information');
49 $labels[] = _('Users and permissions');
50 $labels[] = _('Tools');
51 $labels[] = _('Project History');
52 if(forge_get_config('use_people')) {
53 $labels[] = _('Post Jobs');
54 $labels[] = _('Edit Jobs');
56 if(forge_get_config('use_project_multimedia')) {
57 $labels[] = _('Edit Multimedia Data');
59 if(forge_get_config('use_project_vhost')) {
60 $labels[] = _('VHOSTs');
62 if(forge_get_config('use_project_database')) {
63 $labels[] = _('Database Admin');
65 if ($project->usesStats()) {
66 $labels[] = _('Stats');
68 plugin_hook("quota_label_project_admin");
70 $links[] = '/project/admin/?group_id='.$group_id;
71 $links[] = '/project/admin/users.php?group_id='.$group_id;
72 $links[] = '/project/admin/tools.php?group_id='.$group_id;
73 $links[] = '/project/admin/history.php?group_id='.$group_id;
74 if(forge_get_config('use_people')) {
75 $links[] = '/people/createjob.php?group_id='.$group_id;
76 $links[] = '/people/?group_id='.$group_id;
78 if(forge_get_config('use_project_multimedia')) {
79 $links[] = '/project/admin/editimages.php?group_id='.$group_id;
81 if(forge_get_config('use_project_vhost')) {
82 $links[] = '/project/admin/vhost.php?group_id='.$group_id;
84 if(forge_get_config('use_project_database')) {
85 $links[] = '/project/admin/database.php?group_id='.$group_id;
87 $links[] = '/project/stats/?group_id='.$group_id;
88 plugin_hook("quota_link_project_admin");
90 $params['submenu'] = $HTML->subMenu($labels, $links);
92 plugin_hook ("groupadminmenu", $params) ;
94 site_project_header($params);
99 Standard footer to be used on all /project/admin/* pages
103 function project_admin_footer($params=array()) {
104 site_project_footer($params);
109 The following three functions are for group
112 When changes like adduser/rmuser/change status
113 are made to a group, a row is added to audit trail
114 using group_add_history()
118 function group_get_history ($group_id=false) {
119 return db_query_params("SELECT group_history.field_name,group_history.old_value,group_history.adddate,users.user_name
120 FROM group_history,users
121 WHERE group_history.mod_by=users.user_id
122 AND group_id=$1 ORDER BY group_history.adddate DESC", array($group_id));
125 function group_add_history ($field_name,$old_value,$group_id) {
126 $group=group_get_object($group_id);
127 $group->addHistory($field_name,$old_value);
132 Nicely html-formatted output of this group's audit trail
136 function show_grouphistory ($group_id) {
138 show the group_history rows that are relevant to
142 $result=group_get_history($group_id);
143 $rows=db_numrows($result);
147 echo '<p>'._('This log will show who made significant changes to your project and when').'</p>';
150 $title_arr[]=_('Field');
151 $title_arr[]=_('Old Value');
152 $title_arr[]=_('Date');
153 $title_arr[]=_('By');
155 echo $GLOBALS['HTML']->listTableTop ($title_arr);
156 for ($i=0; $i < $rows; $i++) {
157 $field=db_result($result, $i, 'field_name');
159 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'.$field.'</td><td>';
161 if (is_numeric(db_result($result, $i, 'old_value'))) {
162 if (preg_match("/[Uu]ser/i", $field)) {
163 echo user_getname(db_result($result, $i, 'old_value'));
165 echo db_result($result, $i, 'old_value');
168 echo db_result($result, $i, 'old_value');
171 '<td>'.date(_('Y-m-d H:i'),db_result($result, $i, 'adddate')).'</td>'.
172 '<td>'.db_result($result, $i, 'user_name').'</td></tr>';
175 echo $GLOBALS['HTML']->listTableBottom();
178 echo '<p>'._('No changes').'</p>';
183 prdb_namespace_seek - check that a projects' potential db name hasn't
184 already been used. If it has - add a 1..20 to the end of it. If it
185 iterates through twenty times and still fails - namespace depletion -
189 function prdb_namespace_seek($namecheck) {
191 $query = 'SELECT * FROM prdb_dbs WHERE dbname=$1';
193 $res_dbl = db_query_params($query, array($namecheck));
195 if (db_numrows($res_dbl) > 0) {
196 //crap, we're going to have issues
199 while ((db_numrows($res_dbl) > 0) && ($curr_num < 20)) {
202 $namecheck .= $namecheck.$curr_num;
204 $res_dbl = db_query_params($query, array($namecheck));
207 // if we reached 20, then the namespace is depleted - eject eject
208 if ($curr_num == 20) {
209 exit_error(_('Failed to find namespace for database'),'home');
215 } //end prdb_namespace_seek()
217 function random_pwgen() {
219 srand ( (double) microtime()*10000000);
222 for ($i = 0; $i < 10; $i++) {
229 $rnpw .= chr(rand(65,122));
236 function permissions_blurb() {
237 return _('<strong>NOTE:</strong><dl><dt><strong>Project Admins (bold)</strong></dt><dd>can access this page and other project administration pages</dd><dt><strong>Release Technicians</strong></dt><dd>can make the file releases (any project admin also a release technician)</dd><dt><strong>Tool Technicians (T)</strong></dt><dd>can be assigned Bugs/Tasks/Patches</dd><dt><strong>Tool Admins (A)</strong></dt><dd>can make changes to Bugs/Tasks/Patches as well as use the /toolname/admin/ pages</dd><dt><strong>Tool No Permission (N/A)</strong></dt><dd>Developer doesn\'t have specific permission (currently equivalent to \'-\')</dd><dt><strong>Moderators</strong> (forums)</dt><dd>can delete messages from the project forums</dd><dt><strong>Editors</strong> (doc. manager)</dt><dd>can update/edit/remove documentation from the project.</dd></dl>');
242 // c-file-style: "bsd"