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')) {
52 if (getStringFromRequest('submit')) {
53 $repo_name = trim(getStringFromRequest('repo_name'));
54 $description = preg_replace('/[\r\n]/', ' ', getStringFromRequest('description'));
55 $clone = getStringFromRequest('clone');
56 $hook_params = array () ;
57 $hook_params['group_id'] = $group_id;
58 $hook_params['repo_name'] = $repo_name;
59 $hook_params['description'] = $description;
60 $hook_params['clone'] = $clone;
61 $hook_params['error_msg'] = '';
62 plugin_hook_by_reference ('scm_add_repo', $hook_params);
63 if ($hook_params['error_msg']) {
64 $error_msg = $hook_params['error_msg'];
67 $feedback = sprintf(_('New repository %s is registered'), $repo_name);
72 elseif (getStringFromRequest('submit')) {
73 $hook_params = array();
74 $hook_params['group_id'] = $group_id;
77 $scmvars = array_keys(_getRequestArray());
78 foreach (_getRequestArray() as $key => $value) {
79 foreach ($scm_list as $scm) {
80 if ($key == strstr($key, $scm . "_")) {
81 $hook_params[$key] = $value;
84 $hook_params[$scm] = getArrayFromRequest($scm);
87 if ($key == strstr($key, "scm_")) {
88 $hook_params[$key] = $value;
89 } elseif ($key == 'scmradio') {
94 $SCMFactory = new SCMFactory();
95 $scm_plugins = $SCMFactory->getSCMs();
97 if (in_array($scmradio, $scm_plugins)) {
98 foreach ($scm_plugins as $plugin) {
99 $myPlugin = plugin_get_object($plugin);
100 if ($scmradio == $myPlugin->name) {
101 $group->setPluginUse($myPlugin->name, 1);
103 $group->setPluginUse($myPlugin->name, 0);
108 plugin_hook("scm_admin_update", $hook_params);
111 $hook_params = array();
112 $hook_params['group_id'] = $group_id;
113 plugin_hook('scm_admin_buttons', $hook_params);
115 scm_header(array('title'=>_('SCM Repository'),'group'=>$group_id));
117 <script type="text/javascript">
118 $(document).ready(function() {
119 $("input[type=radio][name=scmradio]").change(function() {
120 $("input[type=radio][name=scmradio]").each(function () {
121 $('#div_'+$(this).val()).hide();
123 $('#div_'+$("input[type=radio][name=scmradio]:checked").val()).show();
127 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>">
130 $hook_params = array () ;
131 $hook_params['group_id'] = $group_id ;
133 $SCMFactory = new SCMFactory();
134 $scm_plugins = $SCMFactory->getSCMs();
135 if (count($scm_plugins) != 0) {
136 if (count($scm_plugins) == 1) {
137 $myPlugin = plugin_get_object($scm_plugins[0]);
138 echo '<input type="hidden" name="scmradio" value="'.$myPlugin->name.'" />' ;
140 echo '<p>'._('Note: Changing the repository does not delete the previous repository. It only affects the information displayed under the SCM tab.').'</p>';
141 echo '<table><tbody><tr><td><strong>'._('SCM Repository').'</strong></td>';
143 foreach ($scm_plugins as $plugin) {
144 $myPlugin = plugin_get_object($plugin);
145 echo '<td><input type="radio" name="scmradio" ';
146 echo 'value="'.$myPlugin->name.'"';
147 if ($group->usesPlugin($myPlugin->name)) {
148 $scm = $myPlugin->name;
149 echo ' checked="checked"';
151 echo ' />'.$myPlugin->text.'</td>';
153 echo '</tr></tbody></table>'."\n";
156 echo '<p class="error_msg">'._('Error - Site has SCM but no plugins registered').'</p>';
159 (isset($scm)) ? $hook_params['scm_plugin'] = $scm : $hook_params['scm_plugin'] = 0;
160 plugin_hook("scm_admin_page", $hook_params);
162 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
163 <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
171 // c-file-style: "bsd"