3 * Project Admin: Module of common functions
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
9 * This file is part of GForge.
11 * GForge 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 * GForge 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 GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 Standard header to be used on all /project/admin/* pages
33 function project_admin_header($params) {
34 global $group_id,$feedback,$HTML;
36 $params['toptab']='admin';
37 $params['group']=$group_id;
39 $project =& group_get_object($group_id);
40 if (!$project || !is_object($project)) {
44 $perm =& $project->getPermission( session_get_user() );
45 if (!$perm || !is_object($perm)) {
50 Enforce Project Admin Perms
52 if (!$perm->isAdmin()) {
53 exit_permission_denied();
56 site_project_header($params);
61 //$labels[] = _('Admin');
62 $labels[] = _('Edit Public Info');
63 $labels[] = _('Project History');
64 if($GLOBALS['sys_use_people']) {
65 $labels[] = _('Post Jobs');
66 $labels[] = _('Edit Jobs');
68 if($GLOBALS['sys_use_project_multimedia']) {
69 $labels[] = _('Edit Multimedia Data');
71 if($GLOBALS['sys_use_project_vhost']) {
72 $labels[] = _('VHOSTs');
74 if($GLOBALS['sys_use_project_database']) {
75 $labels[] = _('Database Admin');
77 $labels[] = _('Stats');
78 plugin_hook("quota_label_project_admin");
80 //$links[] = '/project/admin/?group_id='.$group_id;
81 $links[] = '/project/admin/editgroupinfo.php?group_id='.$group_id;
82 $links[] = '/project/admin/history.php?group_id='.$group_id;
83 if($GLOBALS['sys_use_people']) {
84 $links[] = '/people/createjob.php?group_id='.$group_id;
85 $links[] = '/people/?group_id='.$group_id;
87 if($GLOBALS['sys_use_project_multimedia']) {
88 $links[] = '/project/admin/editimages.php?group_id='.$group_id;
90 if($GLOBALS['sys_use_project_vhost']) {
91 $links[] = '/project/admin/vhost.php?group_id='.$group_id;
93 if($GLOBALS['sys_use_project_database']) {
94 $links[] = '/project/admin/database.php?group_id='.$group_id;
96 $links[] = '/project/stats/?group_id='.$group_id;
97 plugin_hook("quota_link_project_admin");
99 echo ($HTML->beginSubMenu());
100 echo $HTML->printSubMenu($labels, $links);
101 plugin_hook ("groupadminmenu", $params) ;
102 echo ($HTML->endSubMenu());
107 Standard footer to be used on all /project/admin/* pages
111 function project_admin_footer($params) {
112 site_project_footer($params);
117 The following three functions are for group
120 When changes like adduser/rmuser/change status
121 are made to a group, a row is added to audit trail
122 using group_add_history()
126 function group_get_history ($group_id=false) {
127 $sql="SELECT group_history.field_name,group_history.old_value,group_history.adddate,users.user_name ".
128 "FROM group_history,users ".
129 "WHERE group_history.mod_by=users.user_id ".
130 "AND group_id='$group_id' ORDER BY group_history.adddate DESC";
131 return db_query($sql);
134 function group_add_history ($field_name,$old_value,$group_id) {
135 $group=group_get_object($group_id);
136 $group->addHistory($field_name,$old_value);
141 Nicely html-formatted output of this group's audit trail
145 function show_grouphistory ($group_id) {
147 show the group_history rows that are relevant to
151 $result=group_get_history($group_id);
152 $rows=db_numrows($result);
157 <h3>'._('Group Change History').'</h3>
160 $title_arr[]=_('Field');
161 $title_arr[]=_('Old Value');
162 $title_arr[]=_('Date');
163 $title_arr[]=_('By');
165 echo $GLOBALS['HTML']->listTableTop ($title_arr);
166 for ($i=0; $i < $rows; $i++) {
167 $field=db_result($result, $i, 'field_name');
169 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'.$field.'</td><td>';
171 if (is_numeric(db_result($result, $i, 'old_value'))) {
172 if (ereg("user|User", $field)) {
173 echo user_getname(db_result($result, $i, 'old_value'));
175 echo db_result($result, $i, 'old_value');
178 echo db_result($result, $i, 'old_value');
181 '<td>'.date(_('Y-m-d H:i'),db_result($result, $i, 'adddate')).'</td>'.
182 '<td>'.db_result($result, $i, 'user_name').'</td></tr>';
185 echo $GLOBALS['HTML']->listTableBottom();
189 <h3>'._('No changes').'</h3>';
194 prdb_namespace_seek - check that a projects' potential db name hasn't
195 already been used. If it has - add a 1..20 to the end of it. If it
196 iterates through twenty times and still fails - namespace depletion -
200 function prdb_namespace_seek($namecheck) {
204 ."where dbname = '$namecheck'";
206 $res_dbl = db_query($query);
208 if (db_numrows($res_dbl) > 0) {
209 //crap, we're going to have issues
212 while ((db_numrows($res_dbl) > 0) && ($curr_num < 20)) {
215 $namecheck .= "$namecheck"."$curr_num";
219 ."where dbname = '$namecheck'";
221 $res_dbl = db_query($query);
224 // if we reached 20, then the namespace is depleted - eject eject
225 if ($curr_num == 20) {
226 exit_error("Namespace Failure","Failed to find namespace for database");
232 } //end prdb_namespace_seek()
234 function random_pwgen() {
236 srand ( (double) microtime()*10000000);
239 for ($i = 0; $i < 10; $i++) {
246 $rnpw .= chr(rand(65,122));
253 function permissions_blurb() {
254 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>');
259 // c-file-style: "bsd"