<?php
/**
- * GForge SCM Frontend
+ * SCM Frontend
*
- * Copyright 2004 (c) Roland Mas, GForge LLC
+ * Copyright 2004 (c) Roland Mas, Tim Perdue GForge LLC
+ * http://fusionforge.org
*
- * @author Tim Perdue tim@gforge.org
- * @date 2004-05-19
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
*
- * This file is part of GForge.
- *
- * GForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GForge is distributed in the hope that it will be useful,
+ * FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with GForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-require_once('../../env.inc.php');
+require_once '../../env.inc.php';
require_once $gfcommon.'include/pre.php';
+require_once $gfwww.'project/admin/project_admin_utils.php';
require_once $gfwww.'scm/include/scm_utils.php';
require_once $gfcommon.'scm/SCMFactory.class.php';
-
+html_use_jquery();
+html_use_coolfieldset();
$group_id = getIntFromRequest('group_id');
+$group = group_get_object($group_id);
+if (!$group || !is_object($group)) {
+ exit_no_group();
+} elseif ($group->isError()) {
+ exit_error($group->getErrorMessage(), 'scm');
+}
// Check permissions
-session_require_perm ('project_admin', $group_id) ;
+session_require_perm('project_admin', $group_id);
-scm_header(array('title'=>_('SCM Repository'),'group'=>$group_id));
+if (getStringFromRequest('form_create_repo')) {
+ $hook_params = array();
+ $hook_params['group_id'] = $group_id;
+ plugin_hook('scm_admin_form', $hook_params);
+ exit;
+}
-if (getStringFromRequest('submit')) {
- $hook_params = array ();
+if (getStringFromRequest('create_repository') && getStringFromRequest('submit')) {
+ $repo_name = trim(getStringFromRequest('repo_name'));
+ $description = preg_replace('/[\r\n]/', ' ', getStringFromRequest('description'));
+ $clone = getStringFromRequest('clone');
+ $hook_params = array () ;
+ $hook_params['group_id'] = $group_id;
+ $hook_params['repo_name'] = $repo_name;
+ $hook_params['description'] = $description;
+ $hook_params['clone'] = $clone;
+ $hook_params['error_msg'] = '';
+ plugin_hook_by_reference('scm_add_repo', $hook_params);
+ if ($hook_params['error_msg']) {
+ $error_msg = $hook_params['error_msg'];
+ }
+ else {
+ $feedback = sprintf(_('New repository %s registered, will be created shortly.'), $repo_name);
+ }
+} elseif (getStringFromRequest('delete_repository') && getStringFromRequest('submit')) {
+ $repo_name = trim(getStringFromRequest('repo_name'));
+ $hook_params = array () ;
+ $hook_params['group_id'] = $group_id;
+ $hook_params['repo_name'] = $repo_name;
+ $hook_params['error_msg'] = '';
+ plugin_hook_by_reference('scm_delete_repo', $hook_params);
+ if ($hook_params['error_msg']) {
+ $error_msg = $hook_params['error_msg'];
+ }
+ else {
+ $feedback = sprintf(_('Repository %s is marked for deletion (actual deletion will happen shortly).'), $repo_name);
+ }
+} elseif (getStringFromRequest('submit')) {
+ $hook_params = array();
$hook_params['group_id'] = $group_id;
$scmradio = '';
- $scmvars = array_keys (_getRequestArray());
+ $scmvars = array_keys(_getRequestArray());
foreach (_getRequestArray() as $key => $value) {
foreach ($scm_list as $scm) {
if ($key == strstr($key, $scm . "_")) {
$hook_params[$key] = $value;
}
+ else {
+ $hook_params[$scm] = getArrayFromRequest($scm);
+ }
}
if ($key == strstr($key, "scm_")) {
$hook_params[$key] = $value;
$scm_plugins = $SCMFactory->getSCMs();
if (in_array($scmradio, $scm_plugins)) {
- $group =& group_get_object($group_id);
-
foreach ($scm_plugins as $plugin) {
$myPlugin = plugin_get_object($plugin);
if ($scmradio == $myPlugin->name) {
$group->setPluginUse($myPlugin->name, 1);
+ if ($myPlugin->getDefaultServer()) {
+ $group->setSCMBox($myPlugin->getDefaultServer());
+ }
} else {
$group->setPluginUse($myPlugin->name, 0);
}
}
}
- plugin_hook ("scm_admin_update", $hook_params);
+ plugin_hook("scm_admin_update", $hook_params);
}
+$hook_params = array();
+$hook_params['group_id'] = $group_id;
+plugin_hook('scm_admin_buttons', $hook_params);
+
+scm_header(array('title'=>_('SCM Repository'),'group'=>$group_id));
?>
+<script type="text/javascript">
+ $(document).ready(function() {
+ $("input[type=radio][name=scmradio]").change(function() {
+ $("input[type=radio][name=scmradio]").each(function () {
+ $('#div_'+$(this).val()).hide();
+ });
+ $('#div_'+$("input[type=radio][name=scmradio]:checked").val()).show();
+ });
+ });
+</script>
<form action="<?php echo getStringFromServer('PHP_SELF'); ?>">
<?php
$hook_params = array () ;
$hook_params['group_id'] = $group_id ;
- $group =& group_get_object($group_id);
$SCMFactory = new SCMFactory();
$scm_plugins = $SCMFactory->getSCMs();
- if (count($scm_plugins) != 0) {
- if (count($scm_plugins) > 1) {
+ if (count($scm_plugins) != 0) {
+ if (count($scm_plugins) == 1) {
+ $myPlugin = plugin_get_object($scm_plugins[0]);
+ echo '<input type="hidden" name="scmradio" value="'.$myPlugin->name.'" />' ;
+ } else {
echo '<p>'._('Note: Changing the repository does not delete the previous repository. It only affects the information displayed under the SCM tab.').'</p>';
echo '<table><tbody><tr><td><strong>'._('SCM Repository').'</strong></td>';
$checked=true;
$scm = $myPlugin->name;
echo ' checked="checked"';
}
- echo '>'.$myPlugin->text.'</td>';
+ echo ' />'.$myPlugin->text.'</td>';
}
echo '</tr></tbody></table>'."\n";
}
} else {
- echo '<p>'._('Error - Site has SCM but no plugins registered').'</p>';
+ echo '<p class="error_msg">'._('Error - Site has SCM but no plugins registered').'</p>';
}
- plugin_hook ("scm_admin_page", $hook_params) ;
+ (isset($scm)) ? $hook_params['scm_plugin'] = $scm : $hook_params['scm_plugin'] = 0;
+ plugin_hook("scm_admin_page", $hook_params);
?>
<input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
<input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
</form>
<?php
+plugin_hook('scm_admin_form', $hook_params);
scm_footer();
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
-
-?>