5 * Copyright 2010, Roland Mas <lolando@debian.org>
7 * Thorsten Glaser <t.glaser@tarent.de>
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 require_once '../../../www/env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfwww.'scm/include/scm_utils.php';
30 $plugin = plugin_get_object('scmgit');
31 $plugin_id = $plugin->getID();
33 $func = getStringFromRequest ('func') ;
36 if (preg_match('!^grouppage/([a-z][-a-z0-9_]+)(/.*)$!', $func, $matches)) {
37 $grp = util_ifsetor($matches[1]);
39 $grp = group_get_object_by_name($grp);
41 if ($grp && is_object($grp) && !$grp->isError()) {
42 session_redirect('/projects/' . $grp->getUnixName() . '/');
44 exit_error(sprintf(_('Cannot locate group for func=%s'), $func), 'scm');
48 case 'request-personal-repo':
49 $group_id = getIntFromRequest ('group_id') ;
50 session_require_perm ('scm', $group_id, 'write') ;
51 $user = session_get_user(); // get the session user
52 $result = db_query_params ('SELECT * FROM scm_personal_repos WHERE group_id=$1 AND user_id=$2 AND plugin_id=$3',
56 if ($result && db_numrows ($result) == 1) {
57 scm_header (array ('title' => _('SCM Repository'), 'group' => $group_id)) ;
58 echo _('You have already requested a personal Git repository for this project. If it does not exist yet, it will be created shortly.') ;
63 $glist = $user->getGroups() ;
64 foreach ($glist as $g) {
65 if ($g->getID() == $group_id) {
66 $result = db_query_params ('INSERT INTO scm_personal_repos (group_id, user_id, plugin_id) VALUES ($1,$2,$3)',
71 scm_header (array ('title' => _('SCM Repository'), 'group' => $group_id)) ;
72 echo _('You have now requested a personal Git repository for this project. If will be created shortly.') ;
80 exit_missing_param () ;
86 // c-file-style: "bsd"