3 * Site Admin page for approving/rejecting new projects
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 (c) Franck Villaume - Capgemini
7 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
8 * Copyright 2016,2022, Franck Villaume - TrivialDev
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
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 along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 // Show no more pending projects per page than specified here
29 require_once '../env.inc.php';
30 require_once $gfcommon.'include/pre.php';
31 require_once $gfcommon.'include/account.php';
32 require_once $gfwww.'include/canned_responses.php';
33 require_once $gfwww.'admin/admin_utils.php';
34 require_once $gfwww.'project/admin/project_admin_utils.php';
35 require_once $gfcommon.'tracker/ArtifactTypes.class.php';
36 require_once $gfcommon.'forum/Forum.class.php';
40 session_require_global_perm ('approve_projects');
42 function activate_group($group_id) {
46 $group = group_get_object($group_id);
48 if (!$group || !is_object($group)) {
49 $error_msg .= _('Error creating group');
51 } elseif ($group->isError()) {
52 $error_msg .= $group->getErrorMessage();
56 if ($group->approve(session_get_user())) {
57 $feedback .= _('Approving Project')._(': ').$group->getUnixName().'<br />';
59 $error_msg .= _('Error when approving Project')._(': ').$group->getUnixName().'<br />';
60 $error_msg .= $group->getErrorMessage();
67 $action = getStringFromRequest('action');
68 if ($action == 'activate') {
69 $group_id = getIntFromRequest('group_id');
70 $list_of_groups = getStringFromRequest('list_of_groups');
72 $groups = explode(',', $list_of_groups);
73 array_walk($groups, 'activate_group');
75 } elseif ($action == 'delete') {
76 $group_id = getIntFromRequest('group_id');
77 $response_id = getIntFromRequest('response_id');
78 $add_to_can = getStringFromRequest('add_to_can');
79 $response_text = getStringFromRequest('response_text');
80 $response_title = getStringFromRequest('response_title');
82 $group = group_get_object($group_id);
83 if (!$group || !is_object($group)) {
85 } elseif ($group->isError()) {
86 exit_error($group->getErrorMessage(), 'admin');
89 if (!$group->setStatus(session_get_user(), 'D')) {
90 exit_error(_('Error during group rejection')._(': ').$this->getErrorMessage(), 'admin');
93 $group->addHistory('rejected', 'x');
95 // Determine whether to send a canned or custom rejection letter and send it
96 if($response_id == 100) {
98 $group->sendRejectionEmail(0, $response_text);
101 add_canned_response($response_title, $response_text);
106 $group->sendRejectionEmail($response_id);
111 site_admin_header(array('title'=>_('Approving Pending Projects')), 'approve_projects');
113 // get current information
114 $res_grp = db_query_params("SELECT * FROM groups WHERE status='P' AND is_template!=1", array(), $LIMIT);
116 $rows = db_numrows($res_grp);
119 echo $HTML->information(_('No Pending Projects to Approve'));
124 if ($rows > $LIMIT) {
125 print '<p>'. _('Pending projects')._(':'). " $LIMIT+ ($LIMIT shown)</p>";
127 print '<p>'. _('Pending projects')._(':'). " $rows</p>";
130 while ($row_grp = db_fetch_array($res_grp)) {
134 <h2><?php echo _('Pending')._(': ').html_e('em', array(), $row_grp['group_name']); ?></h2>
136 <h3><?php echo _('Pre-approval modifications :'); ?></h3>
138 <p><?php echo util_make_link('/admin/groupedit.php?group_id='.$row_grp['group_id'],_('Edit Project Details'));
140 echo util_make_link('/project/admin/?group_id='.$row_grp['group_id'],_('Project Admin'));
142 echo util_make_link('/admin/userlist.php?group_id='.$row_grp['group_id'],_('View/Edit Project Members')); ?></p>
144 <h3><?php echo _('Decision')._(':'); ?></h3>
145 <table><tr class="bottom"><td>
147 echo $HTML->openForm(array('name' => 'approve'.$row_grp['unix_group_name'], 'action' => '/admin/approve-pending.php', 'method' => 'post'));
149 <input type="hidden" name="action" value="activate" />
150 <input type="hidden" name="list_of_groups" value="<?php print $row_grp['group_id']; ?>" />
151 <input type="submit" name="submit" value="<?php echo _('Approve'); ?>" />
152 <?php echo $HTML->closeForm(); ?>
154 </td><td><?php echo _(' or '); ?>
157 echo $HTML->openForm(array('action' => '/admin/approve-pending.php', 'method' => 'post'));
159 <input type="hidden" name="action" value="delete" />
160 <input type="hidden" name="group_id" value="<?php print $row_grp['group_id']; ?>" />
161 <?php echo _('Rejection canned responses'); ?><br />
162 <?php print get_canned_responses();
163 echo util_make_link('/admin/responses_admin.php', _('(manage responses)')); ?>
165 <label for="response_title"><?php echo _('Custom response title and text'); ?></label><br />
166 <input id="response_title" type="text" name="response_title" size="30" maxlength="25"/><br />
167 <textarea name="response_text" rows="10" cols="50"></textarea>
168 <input type="checkbox" name="add_to_can" value="<?php echo _('Yes'); ?>" /><?php echo _('Add this custom response to canned responses') ;?>
170 <input type="submit" name="submit" value="<?php echo _('Reject'); ?>" />
171 <?php echo $HTML->closeForm(); ?>
175 <h3><?php echo _('Project details')._(':'); ?></h3>
181 if (forge_get_config('use_shell')) {
183 <strong><?php echo _('Home Box')._(': ')."</strong></td><td>"; print $row_grp['unix_box']; ?></tr>
185 } //end of sys_use_shell
187 <tr><td><strong><?php echo _('HTTP Domain')._(': ')."</strong></td><td>"; print $row_grp['http_domain']; ?></td>
193 // ########################## OTHER INFO
195 // print "<p><strong>" ._('Other Information')."</strong></p>";
196 print "<tr><td>" ._('Project Unix Name') . _(':'). "</td><td>".$row_grp['unix_group_name']."</td></tr>";
198 print "<tr><td>" ._('Submitted Description')._(':'). "</td><td><blockquote>".$row_grp['short_description']."</blockquote></td></tr>";
200 print "<tr><td>" ._('Purpose of submission')._(':'). "</td><td><blockquote>".$row_grp['register_purpose']."</blockquote></td></tr>";
202 if ($row_grp['license']=="other") {
203 print "<tr><td>" ._('License Other')._(':'). "</td><td><blockquote>".$row_grp['license_other']."</blockquote></td></tr>";
206 if (isset($row_grp['status_comment'])) {
207 print "<tr><td>" ._('Pending reason')._(':'). "</td><td><span class=\"important\">".$row_grp['status_comment']."</span></td></tr>";
211 $project = group_get_object($row_grp['group_id']) ;
212 foreach (get_group_join_requests ($project) as $gjr) {
213 $submitter = user_get_object($gjr->getUserID()) ;
215 ._('Submitted by') .'</td><td>'. make_user_link($submitter->getUnixName(),$submitter->getRealName())
219 if ($row_grp['built_from_template']) {
220 $templateproject = group_get_object($row_grp['built_from_template']) ;
221 print "<tr><td>" . _('Based on template project') . '</td><td>'. $templateproject->getPublicName() .' ('. $templateproject->getUnixName().")</td></tr>";
224 echo "</table><hr />";
227 //list of group_id's of pending projects
228 $arr = util_result_column_to_array($res_grp, 0);
229 $group_list = implode(',', $arr);
231 echo $HTML->openForm(array('action' => '/admin/approve-pending.php', 'method' => 'post'));
233 <p class="align-center">
234 <input type="hidden" name="action" value="activate" />
235 <input type="hidden" name="list_of_groups" value="'.$group_list.'" />
236 <input type="submit" name="submit" value="'._('Approve All On This Page').'" />
238 echo $HTML->closeForm();