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.
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
27 // Show no more pending projects per page than specified here
30 require_once('../env.inc.php');
31 require_once $gfcommon.'include/pre.php';
32 require_once $gfcommon.'include/account.php';
33 require_once $gfwww.'include/canned_responses.php';
34 require_once $gfwww.'admin/admin_utils.php';
35 require_once $gfwww.'project/admin/project_admin_utils.php';
36 require_once $gfcommon.'tracker/ArtifactTypes.class.php';
37 require_once $gfcommon.'forum/Forum.class.php';
39 session_require_global_perm ('approve_projects');
41 function activate_group($group_id) {
45 $group = group_get_object($group_id);
47 if (!$group || !is_object($group)) {
48 $error_msg .= _('Error creating group object');
50 } else if ($group->isError()) {
51 $error_msg .= $group->getErrorMessage();
55 if ($group->approve(session_get_user())) {
56 $feedback .= sprintf(_('Approving Project: %1$s'), $group->getUnixName());
58 $error_msg .= sprintf(_('Error when approving Project: %1$s'), $group->getUnixName()).'<br />';
59 $error_msg .= $group->getErrorMessage();
66 $action = getStringFromRequest('action');
67 if ($action == 'activate') {
68 $group_id = getIntFromRequest('group_id');
69 $list_of_groups = getStringFromRequest('list_of_groups');
71 $groups = explode(',', $list_of_groups);
72 array_walk($groups, 'activate_group');
74 } else if ($action == 'delete') {
75 $group_id = getIntFromRequest('group_id');
76 $response_id = getIntFromRequest('response_id');
77 $add_to_can = getStringFromRequest('add_to_can');
78 $response_text = getStringFromRequest('response_text');
79 $response_title = getStringFromRequest('response_title');
81 $group = group_get_object($group_id);
82 if (!$group || !is_object($group)) {
84 } elseif ($group->isError()) {
85 exit_error($group->getErrorMessage(), 'admin');
88 if (!$group->setStatus(session_get_user(), 'D')) {
89 exit_error(_('Error during group rejection: ').$this->getErrorMessage(), 'admin');
92 $group->addHistory('rejected', 'x');
94 // Determine whether to send a canned or custom rejection letter and send it
95 if($response_id == 100) {
97 $group->sendRejectionEmail(0, $response_text);
100 add_canned_response($response_title, $response_text);
105 $group->sendRejectionEmail($response_id);
110 site_admin_header(array('title'=>_('Approving Pending Projects')), 'approve_projects');
111 echo '<h1>' . _('Approving Pending Projects') . '</h1>';
113 // get current information
114 $res_grp = db_query_params("SELECT * FROM groups WHERE status='P'", array(), $LIMIT);
116 $rows = db_numrows($res_grp);
119 print '<p class="warning_msg">'._('No Pending Projects to Approve').'</p>';
120 site_admin_footer(array());
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)) {
133 <h2><?php echo $row_grp['group_name']; ?></h2>
136 <h3><?php echo util_make_link ('/admin/groupedit.php?group_id='.$row_grp['group_id'],_('[Edit Project Details]')); ?></h3>
139 <h3><?php echo util_make_link ('/project/admin/?group_id='.$row_grp['group_id'],_('Project Admin')); ?></h3>
142 <h3><?php echo util_make_link ('/admin/userlist.php?group_id='.$row_grp['group_id'],_('[View/Edit Project Members]')); ?></h3>
146 <form name="approve.<?php echo $row_grp['unix_group_name'] ?>" action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
147 <input type="hidden" name="action" value="activate" />
148 <input type="hidden" name="list_of_groups" value="<?php print $row_grp['group_id']; ?>" />
149 <input type="submit" name="submit" value="<?php echo _('Approve'); ?>" />
153 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
154 <input type="hidden" name="action" value="delete" />
155 <input type="hidden" name="group_id" value="<?php print $row_grp['group_id']; ?>" />
156 <?php echo _('Canned responses'); ?><br />
157 <?php print get_canned_responses(); ?> <a href="responses_admin.php"><?php echo _('(manage responses)'); ?></a>
159 <?php echo _('Custom response title and text'); ?><br />
160 <input type="text" name="response_title" size="30" maxlength="25" /><br />
161 <textarea name="response_text" rows="10" cols="50"></textarea>
162 <input type="checkbox" name="add_to_can" value="<?php echo _('yes'); ?>" /><?php echo _('Add this custom response to canned responses') ;?>
164 <input type="submit" name="submit" value="<?php echo _('Reject'); ?>" />
172 if (forge_get_config('use_shell')) {
174 <br /><strong><?php echo _('Home Box:')." "; print $row_grp['unix_box']; ?></strong>
176 } //end of sys_use_shell
178 <br /><strong><?php echo _('HTTP Domain:')." "; print $row_grp['http_domain']; ?></strong>
184 // ########################## OTHER INFO
186 print "<p><strong>" ._('Other Information')."</strong></p>";
187 print "<p>" ._('Unix Project Name:'). " ".$row_grp['unix_group_name']."</p>";
189 print "<p>" ._('Submitted Description:'). "</p><blockquote>".$row_grp['register_purpose']."</blockquote>";
191 if ($row_grp['license']=="other") {
192 print "<p>" ._('License Other:'). "</p><blockquote>".$row_grp['license_other']."</blockquote>";
195 if (isset($row_grp['status_comment'])) {
196 print "<p>" ._('Pending reason:'). "</p><span class=\"important\">".$row_grp['status_comment']."</span>";
201 $project = group_get_object ($row_grp['group_id']) ;
202 foreach (get_group_join_requests ($project) as $gjr) {
203 $submitter = user_get_object($gjr->getUserID()) ;
205 .sprintf(_('Submitted by %1$s (%2$s)'), $submitter->getRealName(), $submitter->getUnixName())
209 $res = db_query_params("SELECT u.user_id
210 FROM users u, user_group ug
211 WHERE ug.group_id=$1 AND u.user_id=ug.user_id;", array($row_grp['group_id']));
213 if (db_numrows($res) >= 1) {
214 $submitter =& user_get_object(db_result($res,0,'user_id'));
217 .sprintf(_('Submitted by %1$s (%2$s)'), $submitter->getRealName(), $submitter->getUnixName())
222 if ($row_grp['built_from_template']) {
223 $templateproject = group_get_object ($row_grp['built_from_template']) ;
224 print "<p>" .sprintf(_('Based on template project: %s (%s)'),$templateproject->getPublicName(),$templateproject->getUnixName())."</p>";
230 //list of group_id's of pending projects
231 $arr = util_result_column_to_array($res_grp, 0);
232 $group_list = implode($arr, ',');
235 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
236 <p style="text-align: center;">
237 <input type="hidden" name="action" value="activate" />
238 <input type="hidden" name="list_of_groups" value="'.$group_list.'" />
239 <input type="submit" name="submit" value="'._('Approve All On This Page').'" />
244 site_admin_footer(array());
248 // c-file-style: "bsd"