3 * Project Admin: Module of common functions
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * http://fusionforge.org/
9 * This file is part of FusionForge.
11 * FusionForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with FusionForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 Standard header to be used on all /project/admin/* pages
31 function project_admin_header($params) {
32 global $group_id,$feedback,$HTML;
34 $params['toptab']='admin';
35 $params['group']=$group_id;
37 session_require_perm ('project_admin', $group_id) ;
39 $project =& group_get_object($group_id);
40 if (!$project || !is_object($project)) {
44 site_project_header($params);
45 echo '<h1>' . $params['title'] . '</h1>';
50 $labels[] = _('Project Info');
51 $labels[] = _('Users and permissions');
52 $labels[] = _('Tools');
53 $labels[] = _('Project History');
54 if(forge_get_config('use_people')) {
55 $labels[] = _('Post Jobs');
56 $labels[] = _('Edit Jobs');
58 if(forge_get_config('use_project_multimedia')) {
59 $labels[] = _('Edit Multimedia Data');
61 if(forge_get_config('use_project_vhost')) {
62 $labels[] = _('VHOSTs');
64 if(forge_get_config('use_project_database')) {
65 $labels[] = _('Database Admin');
67 if ($project->usesStats()) {
68 $labels[] = _('Stats');
70 plugin_hook("quota_label_project_admin");
72 $links[] = '/project/admin/?group_id='.$group_id;
73 $links[] = '/project/admin/users.php?group_id='.$group_id;
74 $links[] = '/project/admin/tools.php?group_id='.$group_id;
75 $links[] = '/project/admin/history.php?group_id='.$group_id;
76 if(forge_get_config('use_people')) {
77 $links[] = '/people/createjob.php?group_id='.$group_id;
78 $links[] = '/people/?group_id='.$group_id;
80 if(forge_get_config('use_project_multimedia')) {
81 $links[] = '/project/admin/editimages.php?group_id='.$group_id;
83 if(forge_get_config('use_project_vhost')) {
84 $links[] = '/project/admin/vhost.php?group_id='.$group_id;
86 if(forge_get_config('use_project_database')) {
87 $links[] = '/project/admin/database.php?group_id='.$group_id;
89 $links[] = '/project/stats/?group_id='.$group_id;
90 plugin_hook("quota_link_project_admin");
92 echo ($HTML->beginSubMenu());
93 echo $HTML->printSubMenu($labels, $links);
94 plugin_hook ("groupadminmenu", $params) ;
95 echo ($HTML->endSubMenu());
100 Standard footer to be used on all /project/admin/* pages
104 function project_admin_footer($params=array()) {
105 site_project_footer($params);
110 The following three functions are for group
113 When changes like adduser/rmuser/change status
114 are made to a group, a row is added to audit trail
115 using group_add_history()
119 function group_get_history ($group_id=false) {
120 return db_query_params("SELECT group_history.field_name,group_history.old_value,group_history.adddate,users.user_name
121 FROM group_history,users
122 WHERE group_history.mod_by=users.user_id
123 AND group_id=$1 ORDER BY group_history.adddate DESC", array($group_id));
126 function group_add_history ($field_name,$old_value,$group_id) {
127 $group=group_get_object($group_id);
128 $group->addHistory($field_name,$old_value);
133 Nicely html-formatted output of this group's audit trail
137 function show_grouphistory ($group_id) {
139 show the group_history rows that are relevant to
143 echo '<h1>'._('Project History').'</h1>';
145 $result=group_get_history($group_id);
146 $rows=db_numrows($result);
150 echo '<p>'._('This log will show who made significant changes to your project and when').'</p>';
153 $title_arr[]=_('Field');
154 $title_arr[]=_('Old Value');
155 $title_arr[]=_('Date');
156 $title_arr[]=_('By');
158 echo $GLOBALS['HTML']->listTableTop ($title_arr);
159 for ($i=0; $i < $rows; $i++) {
160 $field=db_result($result, $i, 'field_name');
162 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'.$field.'</td><td>';
164 if (is_numeric(db_result($result, $i, 'old_value'))) {
165 if (preg_match("/[Uu]ser/i", $field)) {
166 echo user_getname(db_result($result, $i, 'old_value'));
168 echo db_result($result, $i, 'old_value');
171 echo db_result($result, $i, 'old_value');
174 '<td>'.date(_('Y-m-d H:i'),db_result($result, $i, 'adddate')).'</td>'.
175 '<td>'.db_result($result, $i, 'user_name').'</td></tr>';
178 echo $GLOBALS['HTML']->listTableBottom();
181 echo '<p>'._('No changes').'</p>';
186 prdb_namespace_seek - check that a projects' potential db name hasn't
187 already been used. If it has - add a 1..20 to the end of it. If it
188 iterates through twenty times and still fails - namespace depletion -
192 function prdb_namespace_seek($namecheck) {
194 $query = 'SELECT * FROM prdb_dbs WHERE dbname=$1';
196 $res_dbl = db_query_params($query, array($namecheck));
198 if (db_numrows($res_dbl) > 0) {
199 //crap, we're going to have issues
202 while ((db_numrows($res_dbl) > 0) && ($curr_num < 20)) {
205 $namecheck .= $namecheck.$curr_num;
207 $res_dbl = db_query_params($query, array($namecheck));
210 // if we reached 20, then the namespace is depleted - eject eject
211 if ($curr_num == 20) {
212 exit_error(_('Failed to find namespace for database'),'home');
218 } //end prdb_namespace_seek()
220 function random_pwgen() {
222 srand ( (double) microtime()*10000000);
225 for ($i = 0; $i < 10; $i++) {
232 $rnpw .= chr(rand(65,122));
239 function permissions_blurb() {
240 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>');
245 // c-file-style: "bsd"