3 * Implement CVS ACLs based on GForge roles
5 * Copyright 2004 GForge, LLC
7 * This file is part of GForge.
9 * GForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * GForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with GForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
24 require_once '../../../www/env.inc.php';
25 require_once $gfcommon.'include/escapingUtils.php';
26 require_once $gfcommon.'include/pre.php';
28 if (!forge_get_config('use_scm')) {
32 $env_group = getStringFromPost('group');
33 $env_user = getStringFromPost('user');
34 # Group must contain 3 - 15 alphanumeric chars or -
35 preg_match("/^([[:alnum:]-]{3,15})$/", $env_group, $matches);
37 # 1. Must only contain alphanumeric chars or _ or -
38 # 2. Must be 3 - 15 chars
39 preg_match("/[[:alnum:]_-]{3,15}/", $env_user, $matches2);
41 if (count($matches) == 0) {
42 exit_error('','Invalid CVS repository : '.$env_group);
44 if (count($matches2) == 0) {
45 exit_error('','Invalid username : '.$env_user);
48 $userName = $matches2[count($matches2)-1];
49 $User =& user_get_object_by_name($userName);
50 if (!$User || !is_object($User)) {
51 exit_error('','User "'.$userName.'"not found');
53 session_set_new($User->getID());
55 $projectName = $matches[count($matches)-1];
56 $Group =& group_get_object_by_name($projectName);
57 if (!$Group || !is_object($Group) || $Group->isError()) {
61 if (! forge_check_perm_for_user ($User, 'scm', $Group->getID(), 'write')) {
62 exit_permission_denied();
70 // c-file-style: "bsd"