3 * Project Registration: Project Information.
5 * This page is used to request data required for project registration:
6 * o Project Public Name
7 * o Project Registration Purpose
9 * o Project Public Description
11 * All these data are more or less strictly validated.
13 * This is last page in registration sequence. Its successful subsmission
14 * leads to creation of new group with Pending status, suitable for approval.
16 * Portions Copyright 1999-2001 (c) VA Linux Systems
17 * Portions Copyright 2002-2004 (c) GForge Team
18 * Portions Copyright 2002-2009 (c) Roland Mas
19 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
20 * Copyright 2012, Jean-Christophe Masson - French National Education Department
21 * Copyright 2013-2014,2016, Franck Villaume - TrivialDev
22 * http://fusionforge.org/
24 * This file is part of FusionForge. FusionForge is free software;
25 * you can redistribute it and/or modify it under the terms of the
26 * GNU General Public License as published by the Free Software
27 * Foundation; either version 2 of the Licence, or (at your option)
30 * FusionForge is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License along
36 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
37 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
40 require_once '../env.inc.php';
41 require_once $gfcommon.'include/pre.php';
42 require_once $gfcommon.'scm/SCMFactory.class.php';
47 // Test if restricted project registration
49 if (forge_get_config('project_registration_restricted')) {
50 session_require_global_perm ('approve_projects', '',
51 sprintf (_('Project registration is restricted on %s, and only administrators can create new projects.'),
52 forge_get_config ('forge_name')));
53 } elseif (!session_loggedin()) {
57 $template_projects = group_get_template_projects() ;
58 sortProjectList ($template_projects) ;
59 $full_name = trim(getStringFromRequest('full_name'));
60 $purpose = trim(getStringFromRequest('purpose'));
61 $description = trim(getStringFromRequest('description'));
62 $unix_name = trim(strtolower(getStringFromRequest('unix_name')));
63 $scm = getStringFromRequest('scm');
64 $built_from_template = getIntFromRequest('built_from_template');
68 if (getStringFromRequest('submit')) {
69 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
70 exit_form_double_submit('my');
77 $template_project = group_get_object($built_from_template);
79 && !$template_project->isError()
80 && $template_project->isTemplate()) {
81 // Valid template selected, nothing to do
82 } elseif (forge_get_config('allow_project_without_template')) {
83 // Empty projects allowed
84 $built_from_template = 0 ;
85 } elseif (count($template_projects) == 0) {
86 // No empty projects allowed, but no template available
87 $built_from_template = 0 ;
89 // No empty projects allowed, picking the first available template
90 $built_from_template = $template_projects[0]->getID() ;
94 if (forge_get_config('use_scm')) {
96 if (forge_get_config('use_scm') && $scm && $scm != 'noscm') {
97 $plugin = plugin_get_object($scm);
99 $scm_host = $plugin->getDefaultServer();
103 $scm_host = forge_get_config('scm_host');
107 if ( !$purpose && forge_get_config ('project_auto_approval') ) {
108 $purpose = _('No purpose given, autoapprove was on');
111 $send_mail = ! forge_get_config ('project_auto_approval') ;
113 $group = new Group();
114 $u = session_get_user();
115 $res = $group->create(
126 # TODO: enable SCM after the project is approved (if ever), to create systasks when needed
127 if ($res && forge_get_config('use_scm') && $plugin) {
128 $group->setUseSCM (true) ;
129 $res = $group->setPluginUse ($scm, true);
131 $group->setUseSCM (false) ;
135 form_release_key(getStringFromRequest("form_key"));
136 $error_msg .= $group->getErrorMessage();
138 site_user_header(array('title'=>_('Registration complete')));
140 if ( !forge_get_config('project_auto_approval') && !forge_check_global_perm('approve_projects')) {
142 printf(_('Your project has been submitted to the %s administrators. Within 72 hours, you will receive notification of their decision and further instructions.'), forge_get_config ('forge_name'));
145 printf(_('Thank you for choosing %s.'), forge_get_config ('forge_name'));
147 } elseif ($group->isError()) {
148 echo $HTML->error_msg($group->getErrorMessage());
150 echo _('Approving Project')._(': ').$group->getUnixName();
153 if (forge_get_config('project_auto_approval')) {
154 $u = user_get_object_by_name(forge_get_config('project_auto_approval_user'));
157 if (!$group->approve($u)) {
158 echo $HTML->error_msg(sprintf(_('Approval Error: %s'), $group->getErrorMessage()));
161 echo _('Your project has been automatically approved. You should receive an email containing further information shortly.');
164 printf(_('Thank you for choosing %s.'), forge_get_config ('forge_name'));
172 } elseif (getStringFromRequest('i_disagree')) {
173 session_redirect('/');
176 site_user_header(array('title'=>_('Register Project')));
180 <?php echo _('To apply for project registration, you should fill in basic information about it. Please read descriptions below carefully and provide complete and comprehensive data. All fields below are mandatory.') ?>
183 echo $HTML->openForm(array('action' => getStringFromServer('PHP_SELF'), 'method' => 'post')); ?>
184 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>"/>
185 <h2><?php echo $index++.'. '._('Project Full Name') ?></h2>
187 <?php echo _('You should start with specifying the name of your project. The “Full Name” is descriptive, and has no arbitrary restrictions (except min 3 characters and max 40 characters).') ?>
190 <label for="full_name">
191 <?php echo _('Full Name') . _(': ') ?><br/>
193 <input id="full_name" required="required" size="40" maxlength="40" type="text" name="full_name" placeholder="<?php echo _('Project Full Name'); ?>" value="<?php echo htmlspecialchars($full_name); ?>" pattern=".{3,40}"/>
197 // Don't display Project purpose if auto approval is on, because it won't be used.
198 if ( !forge_get_config ('project_auto_approval') ) {
199 echo '<h2>'.$index++.'. '._('Project Purpose And Summarization').'</h2>';
201 echo '<label for="purpose">';
202 printf(_('Please provide detailed, accurate description of your project and what %1$s resources and in which way you plan to use. This description will be the basis for the approval or rejection of your project\'s hosting on %1$s, and later, to ensure that you are using the services in the intended way. This description will not be used as a public description of your project. It must be written in English. From 10 to 1500 characters.'), forge_get_config ('forge_name'));
205 echo '<textarea id="purpose" required="required" name="purpose" cols="70" rows="10" placeholder="'. _('Project Purpose And Summarization').'" >';
206 echo htmlspecialchars($purpose);
211 <h2><?php echo $index++.'. '. _('Project Public Description') ?></h2>
213 <label for="description">
214 <?php echo _('This is the description of your project which will be shown on the Project Summary page, in search results, etc. (at least 10 characters)') ?>
218 <textarea id="description" required="required" name="description" cols="70" rows="5" placeholder="<?php echo _('Project Public Description'); ?>" >
219 <?php echo htmlspecialchars($description); ?>
222 <h2><?php echo $index++.'. '._('Project Unix Name') ?></h2>
223 <p><?php echo _('In addition to full project name, you will need to choose short, “Unix” name for your project.') ?></p>
224 <p><?php echo _('The “Unix Name” has several restrictions because it is used in so many places around the site. They are:') ?></p>
226 <li><?php echo _('cannot match the Unix name of any other project;') ?></li>
227 <li><?php echo _('must be between 3 and 15 characters in length;') ?></li>
228 <li><?php echo _('must be in lower case (upper case letters will be converted to lower case);') ?></li>
229 <li><?php echo _('can only contain characters, numbers, and dashes;') ?></li>
230 <li><?php echo _('must be a valid Unix username;') ?></li>
231 <li><?php echo _('cannot match one of our reserved domains;') ?></li>
232 <li><?php echo _('Unix name will never change for this project;') ?></li>
234 <p><?php echo _('Your Unix name is important, however, because it will be used for many things, including:') ?></p>
236 <li><?php printf(_('a web site at <samp>unixname.%s</samp>,'), forge_get_config('web_host')) ?></li>
237 <li><?php echo _('the URL of your source code repository,') ?></li>
238 <?php if (forge_get_config('use_shell')) { ?>
239 <li><?php printf(_('shell access to <span class="tt">unixname.%s</span>,'), forge_get_config('web_host')) ?></li>
241 <li><?php echo _('search engines throughout the site.') ?></li>
244 <label for="unix_name">
245 <?php echo _('Unix Name') . _(':'); ?>
248 <input id="unix_name" required="required" type="text" maxlength="15" size="15" name="unix_name" value="<?php echo htmlspecialchars($unix_name); ?>" placeholder="<?php echo _('Unix Name'); ?>" pattern="[a-z0-9-]{3,15}"/>
252 $SCMFactory = new SCMFactory();
253 $scm_plugins=$SCMFactory->getSCMs();
254 if (forge_get_config('use_scm') && count($scm_plugins) > 0) {
255 echo '<h2>'.$index++.'. '._('Source Code').'</h2>';
256 echo '<p>' . _('You can choose among different SCM for your project, but just one (or none at all). Please select the SCM system you want to use.')."</p>\n";
257 echo '<table><tbody><tr><td><strong>'._('SCM Repository')._(':').'</strong></td>';
259 echo '<label for="noscm">';
261 echo '<input id="noscm" type="radio" name="scm" value="noscm" checked="checked" />'._('No SCM');
263 echo '<input id="noscm" type="radio" name="scm" value="noscm" />'._('No SCM');
267 foreach($scm_plugins as $plugin) {
268 $myPlugin = plugin_get_object($plugin);
270 echo '<input id="'.$myPlugin->name.'" type="radio" name="scm" ';
271 echo 'value="'.$myPlugin->name.'"';
272 if ($scm && strcmp($scm, $myPlugin->name) == 0) {
273 echo ' checked="checked"';
276 echo '<label for="'.$myPlugin->name.'">';
277 echo $myPlugin->text;
281 echo '</tr></tbody></table>'."\n";
284 if (count ($template_projects) > 1) {
285 $tpv_arr = array () ;
286 $tpn_arr = array () ;
287 echo '<h2>'.$index++.'. '._('Project template'). '</h2>';
289 if (forge_get_config('allow_project_without_template')) {
290 printf(_('You can either start from an empty project, or pick a project that will act as a template for yours. Your project will initially have the same configuration as the template (same roles and permissions, same trackers, same set of enabled plugins, and so on).')) ;
292 $tpn_arr[] = _('Start from empty project') ;
294 printf(_('Please pick a project that will act as a template for yours. Your project will initially have the same configuration as the template (same roles and permissions, same trackers, same set of enabled plugins, and so on).')) ;
297 foreach ($template_projects as $tp) {
298 $tpv_arr[] = $tp->getID() ;
299 $tpn_arr[] = $tp->getPublicName() ;
301 echo html_build_select_box_from_arrays ($tpv_arr, $tpn_arr, 'built_from_template', $built_from_template,
302 false, '', false, '') ;
303 } elseif (count ($template_projects) == 1) {
304 if (forge_get_config('allow_project_without_template')) {
305 echo '<h2>'.$index++.'. '._('Project template'). '</h2>';
307 printf(_('You can either start from an empty project, or use the %s project as a template for yours. Your project will initially have the same configuration as the template (same roles and permissions, same trackers, same set of enabled plugins, and so on).'),
308 $template_projects[0]->getPublicName()) ;
310 $tpv_arr = array () ;
311 $tpn_arr = array () ;
313 $tpn_arr[] = _('Start from empty project') ;
314 $tpv_arr[] = $template_projects[0]->getID() ;
315 $tpn_arr[] = $template_projects[0]->getPublicName() ;
316 echo html_build_select_box_from_arrays ($tpv_arr, $tpn_arr, 'built_from_template', $template_projects[0]->getID(),
317 false, '', false, '') ;
319 printf(_('Your project will initially have the same configuration as the %s project (same roles and permissions, same trackers, same set of enabled plugins, and so on).'),
320 $template_projects[0]->getPublicName()) ;
321 echo '<input type="hidden" name="built_from_template" value="'.$template_projects[0]->getID().'" />' ;
326 printf(_('Since no template project is available, your project will start empty.')) ;
327 echo '<input type="hidden" name="built_from_template" value="0" />' ;
332 <p class="align-center">
333 <input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
334 <input type="submit" name="i_disagree" formnovalidate="formnovalidate" value="<?php echo _('Cancel') ?>" />
338 echo $HTML->closeForm();
343 // c-file-style: "bsd"