Index: admin/index.php
===================================================================
--- admin/index.php	(revision 1698)
+++ admin/index.php	(revision 1699)
@@ -63,4 +63,11 @@
 	$core->auth->user_prefs->dashboard->put('quickentry',false,'boolean');
 }
+
+// Handle folded/unfolded sections in admin from user preferences
+$ws = $core->auth->user_prefs->addWorkspace('toggles');
+if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) {
+	$core->auth->user_prefs->toggles->put('unfolded_sections','','string','Folded sections in admin',null,true);
+}
+
 
 # Dashboard icons
Index: admin/js/_index.js
===================================================================
--- admin/js/_index.js	(revision 1638)
+++ admin/js/_index.js	(revision 1699)
@@ -75,5 +75,5 @@
 	$('#quick h3').toggleWithLegend($('#quick').children().not('h3'),{
 		legend_click: true,
-		cookie: 'dcx_quick_entry'
+		user_pref: 'dcx_quick_entry'
 	});
 });
Index: admin/js/_post.js
===================================================================
--- admin/js/_post.js	(revision 1638)
+++ admin/js/_post.js	(revision 1699)
@@ -120,5 +120,5 @@
 		// Hide some fields
 		$('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{
-			cookie: 'dcx_post_notes',
+			user_pref: 'dcx_post_notes',
 			legend_click:true,
 			hide: $('#post_notes').val() == ''
@@ -129,35 +129,35 @@
 		});
 		$('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{
-			cookie: 'dcx_post_lang',
+			user_pref: 'dcx_post_lang',
 			legend_click: true
 		});
 		$('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{
-			cookie: 'dcx_post_password',
+			user_pref: 'dcx_post_password',
 			legend_click: true,
 			hide: $('#post_password').val() == ''
 		});
 		$('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{
-			cookie: 'dcx_post_status',
+			user_pref: 'dcx_post_status',
 			legend_click: true
 		});
 		$('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{
-			cookie: 'dcx_post_dt',
+			user_pref: 'dcx_post_dt',
 			legend_click: true
 		});
 		$('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{
-			cookie: 'dcx_post_format',
+			user_pref: 'dcx_post_format',
 			legend_click: true
 		});
 		$('#cat_id').parent().children('label').toggleWithLegend($('#cat_id'),{
-			cookie: 'cat_id',
+			user_pref: 'cat_id',
 			legend_click: true
 		});
 		$('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{
-			cookie: 'post_url',
+			user_pref: 'post_url',
 			legend_click: true
 		});
 		// We load toolbar on excerpt only when it's ready
 		$('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{
-			cookie: 'dcx_post_excerpt',
+			user_pref: 'dcx_post_excerpt',
 			legend_click: true,
 			hide: $('#post_excerpt').val() == ''
Index: admin/js/common.js
===================================================================
--- admin/js/common.js	(revision 1635)
+++ admin/js/common.js	(revision 1699)
@@ -63,10 +63,13 @@
 		img_off_src: dotclear.img_minus_src,
 		img_off_alt: dotclear.img_minus_alt,
+		unfolded_sections: dotclear.unfolded_sections,
 		hide: true,
 		speed: 0,
 		legend_click: false,
 		fn: false, // A function called on first display,
-		cookie: false,
-		reverse_cookie: false // Reverse cookie behavior
+		user_pref: false,
+		reverse_user_pref: false, // Reverse cookie behavior
+		user_pref:false,
+		reverse_user_pref: false
 	};
 	var p = jQuery.extend(defaults,s);
@@ -78,5 +81,9 @@
 		p.hide = p.reverse_cookie;
 	}
-
+	
+	var set_user_pref = p.hide ^ p.reverse_user_pref;
+	if (p.user_pref && (p.user_pref in p.unfolded_sections)) {
+		p.hide = p.reverse_user_pref;
+	}
 	var toggle = function(i,speed) {
 		speed = speed || 0;
@@ -102,5 +109,4 @@
 			}
 		}
-
 		p.hide = !p.hide;
 	};
@@ -125,4 +131,16 @@
 		}
 		$(ctarget).click(function() {
+			if (p.user_pref && set_user_pref) {
+				if (p.hide ^ p.reverse_user_pref) {
+					jQuery.post('services.php', 
+						{'f':'setSectionFold','section':p.user_pref,'value':1,xd_check: dotclear.nonce},
+						function(data) {});
+				} else {
+					jQuery.post('services.php', 
+						{'f':'setSectionFold','section':p.user_pref,'value':0,xd_check: dotclear.nonce},
+						function(data) {});
+				}
+				jQuery.cookie(p.user_pref,'',{expires: -1});
+			}
 			toggle(i,p.speed);
 			return false;
@@ -348,14 +366,14 @@
 	}
 	$('#blog-menu h3:first').toggleWithLegend($('#blog-menu ul:first'),
-		$.extend({cookie:'dc_blog_menu'},menu_settings)
+		$.extend({user_pref:'dc_blog_menu'},menu_settings)
 	);
 	$('#system-menu h3:first').toggleWithLegend($('#system-menu ul:first'),
-		$.extend({cookie:'dc_system_menu'},menu_settings)
+		$.extend({user_pref:'dc_system_menu'},menu_settings)
 	);
 	$('#plugins-menu h3:first').toggleWithLegend($('#plugins-menu ul:first'),
-		$.extend({cookie:'dc_plugins_menu'},menu_settings)
+		$.extend({user_pref:'dc_plugins_menu'},menu_settings)
 	);
 	$('#favorites-menu h3:first').toggleWithLegend($('#favorites-menu ul:first'),
-		$.extend({cookie:'dc_favorites_menu',hide:false,reverse_cookie:true},menu_settings)
+		$.extend({user_pref:'dc_favorites_menu',hide:false,reverse_user_pref:true},menu_settings)
 	);
 
Index: admin/services.php
===================================================================
--- admin/services.php	(revision 1538)
+++ admin/services.php	(revision 1699)
@@ -26,4 +26,5 @@
 $core->rest->addFunction('setPostMeta',array('dcRestMethods','setPostMeta'));
 $core->rest->addFunction('searchMeta',array('dcRestMethods','searchMeta'));
+$core->rest->addFunction('setSectionFold',array('dcRestMethods','setSectionFold'));
 
 $core->rest->serve();
@@ -412,4 +413,35 @@
 		return $rsp;
 	}
+	
+	public static function setSectionFold($core,$get,$post)
+	{
+		if (empty($post['section'])) {
+			throw new Exception('No section name');
+		}
+		if ($core->auth->user_prefs->toggles === null) {
+			$core->auth->user_prefs->addWorkspace('toggles');
+		}
+		$section = $post['section'];
+		$status = isset($post['value']) && ($post['value'] != 0);
+		if ($core->auth->user_prefs->toggles->prefExists('unfolded_sections')) {
+			$toggles = explode(',',trim($core->auth->user_prefs->toggles->unfolded_sections));
+		} else {
+			$toggles = array();
+		}
+		$k = array_search($section,$toggles);
+		if ($status) { // true == Fold section ==> remove it from unfolded list
+			if ($k !== false) {
+				unset($toggles[$k]);
+			} 
+		} else { // false == unfold section ==> add it to unfolded list
+			if ($k === false) {
+				$toggles[]=$section;
+			}; 
+		}
+		$core->auth->user_prefs->toggles->put('unfolded_sections',join(',',$toggles));
+		return true;
+	}
+		
+	
 }
 ?>
Index: inc/admin/lib.dc.page.php
===================================================================
--- inc/admin/lib.dc.page.php	(revision 1686)
+++ inc/admin/lib.dc.page.php	(revision 1699)
@@ -114,4 +114,5 @@
 		echo
 		self::jsCommon().
+		self::jsToggles().
 		$head;
 
@@ -253,4 +254,5 @@
 		echo
 		self::jsCommon().
+		self::jsToggles().
 		$head;
 
@@ -444,4 +446,25 @@
 	}
 
+	public static function jsToggles()
+	{
+		if($GLOBALS['core']->auth->user_prefs->toggles) {
+			$unfolded_sections = explode(',',$GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections);
+			foreach ($unfolded_sections as $k=>&$v) {
+				if ($v == '') {
+					unset($unfolded_sections[$k]);
+				} else {
+					$v = "'".html::escapeJS($v)."':true";
+				}
+			}
+		} else {
+			$unfolded_sections=array();
+		}
+		return '<script type="text/javascript">'."\n".
+					"//<![CDATA[\n".
+					'dotclear.unfolded_sections = {'.join(",",$unfolded_sections)."};\n".
+					"\n//]]>\n".
+				"</script>\n";
+	}
+	
 	public static function jsCommon()
 	{
@@ -544,5 +567,5 @@
 		self::jsVar('dotclear.msg.load_enhanced_uploader',
 			__('Loading enhanced uploader, please wait.')).
-		"\n//]]>\n".
+			"\n//]]>\n".
 		"</script>\n";
 	}
Index: plugins/attachments/js/post.js
===================================================================
--- plugins/attachments/js/post.js	(revision 1606)
+++ plugins/attachments/js/post.js	(revision 1699)
@@ -1,5 +1,5 @@
 $(function() {
 	$('h5.s-attachments').toggleWithLegend($('.s-attachments').not('h5'),{
-		cookie: 'dcx_attachments',
+		user_pref: 'dcx_attachments',
 		legend_click: true
 	});
Index: plugins/pings/post.js
===================================================================
--- plugins/pings/post.js	(revision 1606)
+++ plugins/pings/post.js	(revision 1699)
@@ -13,5 +13,5 @@
 		}
 		$('h5.ping-services').toggleWithLegend($('p.ping-services'),{
-			cookie: 'dcx_ping_services',
+			user_pref: 'dcx_ping_services',
 			legend_click: true
 		});
Index: plugins/tags/js/post.js
===================================================================
--- plugins/tags/js/post.js	(revision 1606)
+++ plugins/tags/js/post.js	(revision 1699)
@@ -60,5 +60,5 @@
 
 	$('h5 .s-tags').toggleWithLegend($('.s-tags').not('label'),{
-		cookie: 'post_tags',
+		user_pref: 'post_tags',
 		legend_clik: true
 	});
