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
11 * This file is part of GForge.
13 * GForge 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 * GForge 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 GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 Standard header to be used on all /project/admin/* pages
35 function project_admin_header($params) {
36 global $group_id,$feedback,$HTML;
38 $params['toptab']='admin';
39 $params['group']=$group_id;
41 $project =& group_get_object($group_id);
42 if (!$project || !is_object($project)) {
46 $perm =& $project->getPermission( session_get_user() );
47 if (!$perm || !is_object($perm)) {
52 Enforce Project Admin Perms
54 if (!$perm->isAdmin()) {
55 exit_permission_denied();
58 site_project_header($params);
63 //$labels[] = _('Admin');
64 $labels[] = _('Edit Public Info');
65 $labels[] = _('Project History');
66 if($GLOBALS['sys_use_people']) {
67 $labels[] = _('Post Jobs');
68 $labels[] = _('Edit Jobs');
70 if($GLOBALS['sys_use_project_multimedia']) {
71 $labels[] = _('Edit Multimedia Data');
73 if($GLOBALS['sys_use_project_vhost']) {
74 $labels[] = _('VHOSTs');
76 if($GLOBALS['sys_use_project_database']) {
77 $labels[] = _('Database Admin');
79 $labels[] = _('Stats');
80 plugin_hook("quota_label_project_admin");
82 //$links[] = '/project/admin/?group_id='.$group_id;
83 $links[] = '/project/admin/editgroupinfo.php?group_id='.$group_id;
84 $links[] = '/project/admin/history.php?group_id='.$group_id;
85 if($GLOBALS['sys_use_people']) {
86 $links[] = '/people/createjob.php?group_id='.$group_id;
87 $links[] = '/people/?group_id='.$group_id;
89 if($GLOBALS['sys_use_project_multimedia']) {
90 $links[] = '/project/admin/editimages.php?group_id='.$group_id;
92 if($GLOBALS['sys_use_project_vhost']) {
93 $links[] = '/project/admin/vhost.php?group_id='.$group_id;
95 if($GLOBALS['sys_use_project_database']) {
96 $links[] = '/project/admin/database.php?group_id='.$group_id;
98 $links[] = '/project/stats/?group_id='.$group_id;
99 plugin_hook("quota_link_project_admin");
101 echo ($HTML->beginSubMenu());
102 echo $HTML->printSubMenu($labels, $links);
103 plugin_hook ("groupadminmenu", $params) ;
104 echo ($HTML->endSubMenu());
109 Standard footer to be used on all /project/admin/* pages
113 function project_admin_footer($params) {
114 site_project_footer($params);
119 The following three functions are for group
122 When changes like adduser/rmuser/change status
123 are made to a group, a row is added to audit trail
124 using group_add_history()
128 function group_get_history ($group_id=false) {
129 $sql="SELECT group_history.field_name,group_history.old_value,group_history.adddate,users.user_name ".
130 "FROM group_history,users ".
131 "WHERE group_history.mod_by=users.user_id ".
132 "AND group_id='$group_id' ORDER BY group_history.adddate DESC";
133 return db_query($sql);
136 function group_add_history ($field_name,$old_value,$group_id) {
137 $group=group_get_object($group_id);
138 $group->addHistory($field_name,$old_value);
143 Nicely html-formatted output of this group's audit trail
147 function show_grouphistory ($group_id) {
149 show the group_history rows that are relevant to
152 $result=group_get_history($group_id);
153 $rows=db_numrows($result);
158 <h3>'._('Group Change History').'</h3>
161 $title_arr[]=_('Field');
162 $title_arr[]=_('Old Value');
163 $title_arr[]=_('Date');
164 $title_arr[]=_('By');
166 echo $GLOBALS['HTML']->listTableTop ($title_arr);
168 for ($i=0; $i < $rows; $i++) {
169 $field=db_result($result, $i, 'field_name');
171 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td>'.$field.'</td><td>';
173 if ($field=='removed user') {
174 echo user_getname(db_result($result, $i, 'old_value'));
176 echo db_result($result, $i, 'old_value');
179 '<td>'.date(_('Y-m-d H:i'),db_result($result, $i, 'adddate')).'</td>'.
180 '<td>'.db_result($result, $i, 'user_name').'</td></tr>';
183 echo $GLOBALS['HTML']->listTableBottom();
187 <h3>'._('No changes').'</h3>';
192 prdb_namespace_seek - check that a projects' potential db name hasn't
193 already been used. If it has - add a 1..20 to the end of it. If it
194 iterates through twenty times and still fails - namespace depletion -
198 function prdb_namespace_seek($namecheck) {
202 ."where dbname = '$namecheck'";
204 $res_dbl = db_query($query);
206 if (db_numrows($res_dbl) > 0) {
207 //crap, we're going to have issues
210 while ((db_numrows($res_dbl) > 0) && ($curr_num < 20)) {
213 $namecheck .= "$namecheck"."$curr_num";
217 ."where dbname = '$namecheck'";
219 $res_dbl = db_query($query);
222 // if we reached 20, then the namespace is depleted - eject eject
223 if ($curr_num == 20) {
224 exit_error("Namespace Failure","Failed to find namespace for database");
230 } //end prdb_namespace_seek()
232 function random_pwgen() {
234 srand ( (double) microtime()*10000000);
237 for ($i = 0; $i < 10; $i++) {
244 $rnpw .= chr(rand(65,122));
251 function permissions_blurb() {
252 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>');
257 // c-file-style: "bsd"