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
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 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';
38 session_require_global_perm ('approve_projects');
40 function activate_group($group_id) {
44 $group = group_get_object($group_id);
46 if (!$group || !is_object($group)) {
47 $error_msg .= _('Error creating group object');
49 } elseif ($group->isError()) {
50 $error_msg .= $group->getErrorMessage();
54 if ($group->approve(session_get_user())) {
55 $feedback .= sprintf(_('Approving Project: %1$s'), $group->getUnixName()).'<br />';
57 $error_msg .= sprintf(_('Error when approving Project: %1$s'), $group->getUnixName()).'<br />';
58 $error_msg .= $group->getErrorMessage();
65 $action = getStringFromRequest('action');
66 if ($action == 'activate') {
67 $group_id = getIntFromRequest('group_id');
68 $list_of_groups = getStringFromRequest('list_of_groups');
70 $groups = explode(',', $list_of_groups);
71 array_walk($groups, 'activate_group');
73 } elseif ($action == 'delete') {
74 $group_id = getIntFromRequest('group_id');
75 $response_id = getIntFromRequest('response_id');
76 $add_to_can = getStringFromRequest('add_to_can');
77 $response_text = getStringFromRequest('response_text');
78 $response_title = getStringFromRequest('response_title');
80 $group = group_get_object($group_id);
81 if (!$group || !is_object($group)) {
83 } elseif ($group->isError()) {
84 exit_error($group->getErrorMessage(), 'admin');
87 if (!$group->setStatus(session_get_user(), 'D')) {
88 exit_error(_('Error during group rejection: ').$this->getErrorMessage(), 'admin');
91 $group->addHistory('rejected', 'x');
93 // Determine whether to send a canned or custom rejection letter and send it
94 if($response_id == 100) {
96 $group->sendRejectionEmail(0, $response_text);
99 add_canned_response($response_title, $response_text);
104 $group->sendRejectionEmail($response_id);
109 site_admin_header(array('title'=>_('Approving Pending Projects')), 'approve_projects');
111 // get current information
112 $res_grp = db_query_params("SELECT * FROM groups WHERE status='P' AND is_template!=1", array(), $LIMIT);
114 $rows = db_numrows($res_grp);
117 print '<p class="information">'._('No Pending Projects to Approve').'</p>';
118 site_admin_footer(array());
122 if ($rows > $LIMIT) {
123 print '<p>'. _('Pending projects:'). " $LIMIT+ ($LIMIT shown)</p>";
125 print '<p>'. _('Pending projects:'). " $rows</p>";
128 while ($row_grp = db_fetch_array($res_grp)) {
132 <h2><?php echo _('Pending') . ': <i>'. $row_grp['group_name'] . '</i>'; ?></h2>
135 <h3><?php echo _('Pre-approval modifications :'); ?></h3>
137 <p><?php echo util_make_link ('/admin/groupedit.php?group_id='.$row_grp['group_id'],_('[Edit Project Details]'));
139 echo util_make_link ('/project/admin/?group_id='.$row_grp['group_id'],_('[Project Admin]'));
141 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 <form name="approve.<?php echo $row_grp['unix_group_name'] ?>" action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
148 <input type="hidden" name="action" value="activate" />
149 <input type="hidden" name="list_of_groups" value="<?php print $row_grp['group_id']; ?>" />
150 <input type="submit" name="submit" value="<?php echo _('Approve'); ?>" />
153 </td><td><?php echo _(' or '); ?>
156 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
157 <input type="hidden" name="action" value="delete" />
158 <input type="hidden" name="group_id" value="<?php print $row_grp['group_id']; ?>" />
159 <?php echo _('Rejection canned responses'); ?><br />
160 <?php print get_canned_responses(); ?> <a href="responses_admin.php"><?php echo _('(manage responses)'); ?></a>
162 <?php echo _('Custom response title and text'); ?><br />
163 <input type="text" name="response_title" size="30" maxlength="25" /><br />
164 <textarea name="response_text" rows="5" cols="50"></textarea><br />
165 <input type="checkbox" name="add_to_can" value="<?php echo _('yes'); ?>" /><?php echo _('Add this custom response to canned responses') ;?>
167 <input type="submit" name="submit" value="<?php echo _('Reject'); ?>" />
173 <h3><?php echo _('Project details :'); ?></h3>
179 if (forge_get_config('use_shell')) {
181 <strong><?php echo _('Home Box:')."</strong></td><td>"; print $row_grp['unix_box']; ?></tr>
183 } //end of sys_use_shell
185 <tr><td><strong><?php echo _('HTTP Domain:')."</strong></td><td>"; print $row_grp['http_domain']; ?></td>
191 // ########################## OTHER INFO
193 // print "<p><strong>" ._('Other Information')."</strong></p>";
194 print "<tr><td>" ._('Unix Project Name:'). "</td><td>".$row_grp['unix_group_name']."</td></tr>";
196 print "<tr><td>" ._('Submitted Description:'). "</td><td><blockquote>".$row_grp['short_description']."</blockquote></td></tr>";
198 print "<tr><td>" ._('Purpose of submission:'). "</td><td><blockquote>".$row_grp['register_purpose']."</blockquote></td></tr>";
200 if ($row_grp['license']=="other") {
201 print "<tr><td>" ._('License Other:'). "</td><td><blockquote>".$row_grp['license_other']."</blockquote></td></tr>";
204 if (isset($row_grp['status_comment'])) {
205 print "<tr><td>" ._('Pending reason:'). "</td><td><span class=\"important\">".$row_grp['status_comment']."</span></td></tr>";
209 $project = group_get_object ($row_grp['group_id']) ;
210 foreach (get_group_join_requests ($project) as $gjr) {
211 $submitter = user_get_object($gjr->getUserID()) ;
213 ._('Submitted by') .'</td><td>'. make_user_link($submitter->getUnixName(),$submitter->getRealName())
217 if ($row_grp['built_from_template']) {
218 $templateproject = group_get_object ($row_grp['built_from_template']) ;
219 print "<tr><td>" . _('Based on template project') . '</td><td>'. $templateproject->getPublicName() .' ('. $templateproject->getUnixName().")</td></tr>";
222 echo "</table><hr />";
225 //list of group_id's of pending projects
226 $arr = util_result_column_to_array($res_grp, 0);
227 $group_list = implode($arr, ',');
230 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
231 <p class="align-center">
232 <input type="hidden" name="action" value="activate" />
233 <input type="hidden" name="list_of_groups" value="'.$group_list.'" />
234 <input type="submit" name="submit" value="'._('Approve All On This Page').'" />
239 site_admin_footer(array());
243 // c-file-style: "bsd"