3 * Site Admin page for approving/rejecting new projects
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 (c) Franck Villaume - Capgemini
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
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
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 $gfcommon.'include/license.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();
56 if ($group->approve(session_get_user())) {
57 $feedback .= sprintf(_('Approving Project: %1$s'), $group->getUnixName());
59 $error_msg .= sprintf(_('Error when approving Project: %1$s'), $group->getUnixName()).'<br />';
60 $error_msg .= $group->getErrorMessage();
64 $hook_params = array () ;
65 $hook_params['group_id'] = $group_id ;
66 plugin_hook ("group_approved", $hook_params) ;
70 plugin_hook('add_cal_group',$group_id);
75 $action = getStringFromRequest('action');
76 if ($action=='activate') {
77 $group_id = getIntFromRequest('group_id');
78 $list_of_groups = getStringFromRequest('list_of_groups');
80 $groups=explode(',', $list_of_groups);
81 array_walk($groups, 'activate_group');
84 plugin_hook('add_cal_group',$group_id);
86 } else if ($action=='delete') {
87 $group_id = getIntFromRequest('group_id');
88 $response_id = getIntFromRequest('response_id');
89 $add_to_can = getStringFromRequest('add_to_can');
90 $response_text = getStringFromRequest('response_text');
91 $response_title = getStringFromRequest('response_title');
94 plugin_hook('del_cal_group',$group_id);
96 $group =& group_get_object($group_id);
97 if (!$group || !is_object($group)) {
99 } elseif ($group->isError()) {
100 exit_error($group->getErrorMessage(),'admin');
103 if (!$group->setStatus(session_get_user(), 'D')) {
104 exit_error(_('Error during group rejection: ').$this->getErrorMessage(),'admin');
107 $group->addHistory('rejected', 'x');
109 // Determine whether to send a canned or custom rejection letter and send it
110 if( $response_id == 100 ) {
112 $group->sendRejectionEmail(0, $response_text);
115 add_canned_response($response_title, $response_text);
120 $group->sendRejectionEmail($response_id);
125 site_admin_header(array('title'=>_('Approving Pending Projects')));
126 echo '<h1>' . _('Approving Pending Projects') . '</h1>';
128 // get current information
129 $res_grp = db_query_params("SELECT * FROM groups WHERE status='P'", array(), $LIMIT);
131 $rows = db_numrows($res_grp);
134 print '<p class="warning_msg">'._('No Pending Projects to Approve').'</p>';
135 site_admin_footer(array());
139 if ($rows > $LIMIT) {
140 print "<p>"._('Pending projects:'). "$LIMIT+ ($LIMIT shown)</p>";
142 print "<p>"._('Pending projects:'). "$rows</p>";
145 while ($row_grp = db_fetch_array($res_grp)) {
148 <h2><?php echo $row_grp['group_name']; ?></h2>
151 <h3><?php echo util_make_link ('/admin/groupedit.php?group_id='.$row_grp['group_id'],_('[Edit Project Details]')); ?></h3>
154 <h3><?php echo util_make_link ('/project/admin/?group_id='.$row_grp['group_id'],_('Project Admin')); ?></h3>
157 <h3><?php echo util_make_link ('/admin/userlist.php?group_id='.$row_grp['group_id'],_('[View/Edit Project Members]')); ?></h3>
161 <form name="approve.<?php echo $row_grp['unix_group_name'] ?>" action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
162 <input type="hidden" name="action" value="activate" />
163 <input type="hidden" name="list_of_groups" value="<?php print $row_grp['group_id']; ?>" />
164 <input type="submit" name="submit" value="<?php echo _('Approve'); ?>" />
168 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
169 <input type="hidden" name="action" value="delete" />
170 <input type="hidden" name="group_id" value="<?php print $row_grp['group_id']; ?>" />
171 <?php echo _('Canned responses'); ?><br />
172 <?php print get_canned_responses(); ?> <a href="responses_admin.php"><?php echo _('(manage responses)'); ?></a>
174 <?php echo _('Custom response title and text'); ?><br />
175 <input type="text" name="response_title" size="30" maxlength="25" /><br />
176 <textarea name="response_text" rows="10" cols="50"></textarea>
177 <input type="checkbox" name="add_to_can" value="<?php echo _('yes'); ?>" /><?php echo _('Add this custom response to canned responses') ;?>
179 <input type="submit" name="submit" value="<?php echo _('Reject'); ?>" />
185 <strong><?php echo _('License:')." "; print license_getname($row_grp['license']); ?></strong>
189 if (forge_get_config('use_shell')) {
191 <br /><strong><?php echo _('Home Box:')." "; print $row_grp['unix_box']; ?></strong>
193 } //end of sys_use_shell
195 <br /><strong><?php echo _('HTTP Domain:')." "; print $row_grp['http_domain']; ?></strong>
201 // ########################## OTHER INFO
203 print "<p><strong>" ._('Other Information')."</strong></p>";
204 print "<p>" ._('Unix Project Name:'). " ".$row_grp['unix_group_name']."</p>";
206 print "<p>" ._('Submitted Description:'). "</p><blockquote>".$row_grp['register_purpose']."</blockquote>";
208 if ($row_grp['license']=="other") {
209 print "<p>" ._('License Other:'). "</p><blockquote>".$row_grp['license_other']."</blockquote>";
212 if (isset($row_grp['status_comment'])) {
213 print "<p>" ._('Pending reason:'). "</p><span class=\"important\">".$row_grp['status_comment']."</span>";
216 $res = db_query_params("SELECT u.user_id
217 FROM users u, user_group ug
218 WHERE ug.group_id=$1 AND u.user_id=ug.user_id;", array($row_grp['group_id']));
220 if (db_numrows($res) >= 1) {
221 $submitter =& user_get_object(db_result($res,0,'user_id'));
224 .sprintf(_('Submitted by %1$s (%2$s)'), $submitter->getRealName(), $submitter->getUnixName())
231 //list of group_id's of pending projects
232 $arr=util_result_column_to_array($res_grp,0);
233 $group_list=implode($arr,',');
236 <form action="'.getStringFromServer('PHP_SELF').'" method="post">
237 <p style="text-align: center;">
238 <input type="hidden" name="action" value="activate" />
239 <input type="hidden" name="list_of_groups" value="'.$group_list.'" />
240 <input type="submit" name="submit" value="'._('Approve All On This Page').'" />
245 site_admin_footer(array());
249 // c-file-style: "bsd"