5 * Copyright 2004 (c) Roland Mas, Tim Perdue GForge LLC
6 * http://fusionforge.org
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge 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 along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once '../../env.inc.php';
25 require_once $gfcommon.'include/pre.php';
26 require_once $gfwww.'project/admin/project_admin_utils.php';
27 require_once $gfwww.'scm/include/scm_utils.php';
28 require_once $gfcommon.'scm/SCMFactory.class.php';
31 html_use_coolfieldset();
33 $group_id = getIntFromRequest('group_id');
34 $group = group_get_object($group_id);
35 if (!$group || !is_object($group)) {
37 } elseif ($group->isError()) {
38 exit_error($group->getErrorMessage(), 'scm');
42 session_require_perm('project_admin', $group_id);
44 if (getStringFromRequest('form_create_repo')) {
45 $hook_params = array();
46 $hook_params['group_id'] = $group_id;
47 plugin_hook('scm_admin_form', $hook_params);
51 if (getStringFromRequest('create_repository') && getStringFromRequest('submit')) {
52 $repo_name = trim(getStringFromRequest('repo_name'));
53 $description = preg_replace('/[\r\n]/', ' ', getStringFromRequest('description'));
54 $clone = getStringFromRequest('clone');
55 $hook_params = array () ;
56 $hook_params['group_id'] = $group_id;
57 $hook_params['repo_name'] = $repo_name;
58 $hook_params['description'] = $description;
59 $hook_params['clone'] = $clone;
60 $hook_params['error_msg'] = '';
61 plugin_hook_by_reference('scm_add_repo', $hook_params);
62 if ($hook_params['error_msg']) {
63 $error_msg = $hook_params['error_msg'];
66 $feedback = sprintf(_('New repository %s registered, will be created shortly.'), $repo_name);
68 } elseif (getStringFromRequest('delete_repository') && getStringFromRequest('submit')) {
69 $repo_name = trim(getStringFromRequest('repo_name'));
70 $hook_params = array () ;
71 $hook_params['group_id'] = $group_id;
72 $hook_params['repo_name'] = $repo_name;
73 $hook_params['error_msg'] = '';
74 plugin_hook_by_reference('scm_delete_repo', $hook_params);
75 if ($hook_params['error_msg']) {
76 $error_msg = $hook_params['error_msg'];
79 $feedback = sprintf(_('Repository %s is marked for deletion (actual deletion will happen shortly).'), $repo_name);
81 elseif (getStringFromRequest('submit')) {
82 $hook_params = array();
83 $hook_params['group_id'] = $group_id;
86 $scmvars = array_keys(_getRequestArray());
87 foreach (_getRequestArray() as $key => $value) {
88 foreach ($scm_list as $scm) {
89 if ($key == strstr($key, $scm . "_")) {
90 $hook_params[$key] = $value;
93 $hook_params[$scm] = getArrayFromRequest($scm);
96 if ($key == strstr($key, "scm_")) {
97 $hook_params[$key] = $value;
98 } elseif ($key == 'scmradio') {
103 $SCMFactory = new SCMFactory();
104 $scm_plugins = $SCMFactory->getSCMs();
106 if (in_array($scmradio, $scm_plugins)) {
107 foreach ($scm_plugins as $plugin) {
108 $myPlugin = plugin_get_object($plugin);
109 if ($scmradio == $myPlugin->name) {
110 $group->setPluginUse($myPlugin->name, 1);
111 if ($myPlugin->getDefaultServer()) {
112 $group->setSCMBox($myPlugin->getDefaultServer());
115 $group->setPluginUse($myPlugin->name, 0);
120 plugin_hook("scm_admin_update", $hook_params);
123 $hook_params = array();
124 $hook_params['group_id'] = $group_id;
125 plugin_hook('scm_admin_buttons', $hook_params);
127 scm_header(array('title'=>_('SCM Repository'),'group'=>$group_id));
129 <script type="text/javascript">
130 $(document).ready(function() {
131 $("input[type=radio][name=scmradio]").change(function() {
132 $("input[type=radio][name=scmradio]").each(function () {
133 $('#div_'+$(this).val()).hide();
135 $('#div_'+$("input[type=radio][name=scmradio]:checked").val()).show();
139 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>">
142 $hook_params = array () ;
143 $hook_params['group_id'] = $group_id ;
145 $SCMFactory = new SCMFactory();
146 $scm_plugins = $SCMFactory->getSCMs();
147 if (count($scm_plugins) != 0) {
148 if (count($scm_plugins) == 1) {
149 $myPlugin = plugin_get_object($scm_plugins[0]);
150 echo '<input type="hidden" name="scmradio" value="'.$myPlugin->name.'" />' ;
152 echo '<p>'._('Note: Changing the repository does not delete the previous repository. It only affects the information displayed under the SCM tab.').'</p>';
153 echo '<table><tbody><tr><td><strong>'._('SCM Repository').'</strong></td>';
155 foreach ($scm_plugins as $plugin) {
156 $myPlugin = plugin_get_object($plugin);
157 echo '<td><input type="radio" name="scmradio" ';
158 echo 'value="'.$myPlugin->name.'"';
159 if ($group->usesPlugin($myPlugin->name)) {
160 $scm = $myPlugin->name;
161 echo ' checked="checked"';
163 echo ' />'.$myPlugin->text.'</td>';
165 echo '</tr></tbody></table>'."\n";
168 echo '<p class="error_msg">'._('Error - Site has SCM but no plugins registered').'</p>';
171 (isset($scm)) ? $hook_params['scm_plugin'] = $scm : $hook_params['scm_plugin'] = 0;
172 plugin_hook("scm_admin_page", $hook_params);
174 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
175 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
179 plugin_hook('scm_admin_form', $hook_params);
184 // c-file-style: "bsd"