From 37aa05abe53c317de841cd24a283a8629a3795f2 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind1991@gmail.com>
Date: Sat, 4 Sep 2010 21:30:49 +0000
Subject: [PATCH] remember the selected tab in the settings dialog when
 refreshing the page or submiting forms

---
 inc/templates/adminform.php |  6 +++---
 inc/templates/settings.php  | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/inc/templates/adminform.php b/inc/templates/adminform.php
index 394df38da7..0a892d7d4b 100644
--- a/inc/templates/adminform.php
+++ b/inc/templates/adminform.php
@@ -53,11 +53,11 @@ function dbtypechange(){
 </script>
 <?php
 if(!$FIRSTRUN){
-	$action=$WEBROOT.'/settings';
+	$action=$WEBROOT.'/settings/#system_settings';
 }else{
 	$action='#';
 }
-echo('<form method="post" enctype="multipart/form-data" action="'.$action.'">')
+echo('<form method="post" action="'.$action.'">')
 ?>
 <table cellpadding="5" cellspacing="5" border="0" class="loginform">
 <?php
@@ -134,7 +134,7 @@ if($CONFIG_DBTYPE=='sqlite'){
 <tr id='dbAdminPwd'><td>database administrative password:</td><td><input type="password" name="dbadminpwd" size="30" class="formstyle" value=''></input></td></tr>
 <tr id='dbfill'><td>automaticly fill initial database:</td><td><input type="checkbox" name="filldb" size="30" class="formstyle" value='1' <?php if($FIRSTRUN) echo 'checked="checked"'; ?>></input></td></tr>
 <?php }?>
-<tr><td></td><td><input type="submit" name="set_config" alt="save" value="save" class="formstyle" /></td></tr>
+<tr><td></td><td><input type="submit" name='set_config' alt="save" value="save" class="formstyle" /></td></tr>
 </table></form><br/>
 <?php
 if(!$FIRSTRUN ){//disabled for now?>
diff --git a/inc/templates/settings.php b/inc/templates/settings.php
index ef181164d0..9a1876f98a 100644
--- a/inc/templates/settings.php
+++ b/inc/templates/settings.php
@@ -5,6 +5,14 @@ function showForm(id){
 	form.setAttribute('class','settingsContent');
 }
 
+function showFormInit(){
+	var loc=document.location.toString();
+	if(loc.indexOf('#')!=-1){
+		var id=loc.substring(loc.indexOf('#')+1);
+		showForm(id);
+	}
+}
+
 function hideAllForms(){
 	forms=document.getElementById('settingsHolder').childNodes;
 	for(var i=0;i<forms.length;i++){
@@ -36,3 +44,6 @@ foreach(OC_CONFIG::$forms as $name=>$url){
 }
 ?>
 </div>
+<script type="text/javascript">
+OC_onload.add(showFormInit());
+</script>
\ No newline at end of file
-- 
GitLab