From b21c6b13de14f6279041ecd40ba16535f7f14754 Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Tue, 9 Mar 2010 08:18:04 +0000 Subject: [PATCH] "MDL-13766, improve repository settings" --- admin/repository.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/admin/repository.php b/admin/repository.php index fa4c7d559fc..74c8b2b0f6e 100644 --- a/admin/repository.php +++ b/admin/repository.php @@ -28,9 +28,8 @@ require_login(SITEID, false); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); admin_externalpage_setup($pagename); -$sesskeyurl = "$CFG->wwwroot/$CFG->admin/repository.php?sesskey=" . sesskey(); -$baseurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managerepositories"; - +$sesskeyurl = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php?sesskey=' . sesskey(); +$baseurl = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=managerepositories'; $configstr = get_string('managerepositories', 'repository'); @@ -43,9 +42,9 @@ if (!empty($edit) || !empty($new)) { $configs = call_user_func(array($classname,'get_type_option_names')); $plugin = $repositorytype->get_typename(); } else { + $repositorytype = null; $plugin = $new; $typeid = $new; - $repositorytype = null; } $PAGE->set_pagetype('admin-repository-' . $plugin); // display the edit form for this instance @@ -53,16 +52,16 @@ if (!empty($edit) || !empty($new)) { $fromform = $mform->get_data(); //detect if we create a new type without config (in this case if don't want to display a setting page during creation) - $createnewtype = false; + $nosettings = false; if (!empty($new)) { $adminconfignames = repository::static_function($new, 'get_type_option_names'); - $createnewtype = empty($adminconfignames); + $nosettings = empty($adminconfignames); } // end setup, begin output + if ($mform->is_cancelled()){ redirect($baseurl); - exit; - } else if (!empty($fromform) || $createnewtype){ + } else if (!empty($fromform) || $nosettings) { if (!confirm_sesskey()) { print_error('confirmsesskeybad', '', $baseurl); } @@ -94,14 +93,22 @@ if (!empty($edit) || !empty($new)) { } $success = $repositorytype->update_options($settings); } else { - $type = new repository_type($plugin,(array)$fromform); + $type = new repository_type($plugin, (array)$fromform); $type->create(); $success = true; $data = data_submitted(); } if ($success) { $savedstr = get_string('configsaved', 'repository'); - redirect($baseurl, $savedstr, 3); + $has_instance = repository::static_function($plugin, 'get_instance_option_names'); + + if (!empty($has_instance)) { + // no common setting for this type, so go to setup instances + redirect($sesskeyurl.'&edit='.$plugin, $savedstr, 1); + } else { + // configs saved + redirect($baseurl, $savedstr, 1); + } } else { print_error('instancenotsaved', 'repository', $baseurl); }