--- redmine_backup/vendor/plugins/redcase/assets/javascripts/scripts.js	2011-01-10 19:16:37.000000000 +0000
+++ redmine/vendor/plugins/redcase/assets/javascripts/scripts.js	2012-01-07 20:10:08.000000000 +0000
@@ -21,7 +21,6 @@
 Ext.dd.StatusProxy.prototype.animRepair = false;
 Ext.QuickTips.init();
 Ext.chart.Chart.CHART_URL = '/plugin_assets/redcase/javascripts/ext-3.1.1/resources/charts.swf';
-
 Ext.override(Ext.tree.TreeNodeUI,
 {
 	renderElements: function(n, a, targetNode, bulkRender)
@@ -239,8 +238,12 @@
 
 function request(method, params, success, failureMsg)
 {
-	params.format = 'json';
-	conn = new Ext.data.Connection();
+        params.format = 'json';
+	conn = new Ext.data.Connection();
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
+
+        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	conn.request(
 	{
 		url     : context + method,
@@ -258,7 +261,9 @@
  * Moving test case inside 'Test cases' tree.
  */
 function onMove(dropEvent)
-{
+{
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	if(dropEvent.dropNode.isLeaf())
 	{
 		request(
@@ -306,7 +311,10 @@
 function onxMove(dropEvent)
 {
 	conn = new Ext.data.Connection();
-
+        
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
+        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	if(dropEvent.dropNode.isLeaf())
 	{
 		if(dropEvent.target.getOwnerTree() != dropEvent.dropNode.getOwnerTree())
@@ -425,7 +433,12 @@
 	{
 		if (btn == 'ok')
 		{
-			conn = new Ext.data.Connection();
+			conn = new Ext.data.Connection();
+                        
+
+                        var csrf = Ext.select("meta[name='csrf-token']").first();
+                        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
+                        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 			conn.request(
 			{
 				url     : 'redcase/test_suite_manager',
@@ -463,7 +476,9 @@
 
 	parentNode = currentNode.parentNode;
 	conn = new Ext.data.Connection();
-
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});        
+        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	if(currentNode.isLeaf())
 	{
 		conn.request(
@@ -520,7 +535,9 @@
 
 	parentNode = currentNode.parentNode;
 	conn = new Ext.data.Connection();
-
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
+        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	conn.request(
 	{
 		url    : 'redcase/reassign_test_case',
@@ -548,7 +565,10 @@
 	{
 		if (btn == 'ok')
 		{
-			conn = new Ext.data.Connection();
+			conn = new Ext.data.Connection();
+                        var csrf = Ext.select("meta[name='csrf-token']").first();
+                        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')}); 
+                        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 			conn.request(
 			{
 				url     : 'redcase/execution_suite_manager',
@@ -591,7 +611,10 @@
 		return;
 	}
 	parentNode = currentNode.parentNode;
-	conn = new Ext.data.Connection();
+	conn = new Ext.data.Connection();
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});        
+        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	conn.disableCaching = false;
 	if (currentNode.isLeaf())
 	{
@@ -620,7 +643,9 @@
 
 	parentNode = xcurrentNode.parentNode;
 	conn = new Ext.data.Connection();
-
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
+        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	if (xcurrentNode.isLeaf())
 	{
 		conn.request(
@@ -741,7 +766,10 @@
 
 	editorSuite.on('beforecomplete', function(editor, newValue, originalValue) {
 
-		conn = new Ext.data.Connection();
+		conn = new Ext.data.Connection();
+                var csrf = Ext.select("meta[name='csrf-token']").first();
+                Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
+                conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 
 		conn.request({
 			url: 'redcase/test_suite_manager',
@@ -774,7 +802,9 @@
 	editorExec.on('beforecomplete', function(editor, newValue, originalValue) {
 
 		conn = new Ext.data.Connection();
-
+                var csrf = Ext.select("meta[name='csrf-token']").first();
+                Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
+                conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 		conn.request({
 			url: 'redcase/execution_suite_manager',
 			method: 'GET',
@@ -864,15 +894,16 @@
 		return findNext(next);
 	}
 }
-
-
-function execute() {
+function execute() {
 	node = exec2Tree.getSelectionModel().getSelectedNode();
 	result = Ext.get('results');
 	envs = Ext.get('environments');
 	version = Ext.get('version');
 	comment = Ext.get('exec-comment');
-	conn = new Ext.data.Connection();
+	conn = new Ext.data.Connection();
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
+        conn.defaultHeaders = Ext.apply(conn.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	Element.show('ajax-indicator');
 	conn.request({
 		url: 'redcase/execute',
@@ -883,7 +914,7 @@
 			"version": version.getValue(false),
 			"result": result.getValue(false),
 			"envs": envs.getValue(false),
-			"comment": comment.getValue(false),
+			"comment": comment.getValue(false),
 			"format": "json"
 		},
 		success: function(responseObject) {
@@ -912,7 +943,9 @@
 	r = Ext.get('all-results-d');
 	r.setDisplayed('none');
 	if (node.isLeaf()) {
-		conn = new Ext.data.Connection();
+		conn = new Ext.data.Connection();
+                var csrf = Ext.select("meta[name='csrf-token']").first();
+                Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 		Element.show('ajax-indicator');
 		conn.request({
 			waitMsg: 'loading test case info',
@@ -999,9 +1032,9 @@
 
 function getHistory(rs)
 {
-	unique = {}
-	txt = "<table class='redcase-row' width='100%'>"
-	txt += "<tr style='font-weight: bold; background-color: #eeeeee'><td>Date</td><td>Result</td><td>Comments</td><td>Executor</td><td>Environment</td><td>Version</td></tr>"
+	unique = {}
+        txt = "<table class='redcase-row' width='100%'>"
+        txt += "<tr style='font-weight: bold; background-color: #eeeeee'><td>date</td><td>result</td><td>comments</td><td>executor</td><td>environment</td><td>version</td></tr>";
 	for(i = 0; i < rs.length; i++) {
 		switch (rs[i].result)
 		{
@@ -1076,11 +1109,11 @@
 function update_exe_tree()
 {
 	choosen = Ext.get('list_id').getValue(false);
-	conn = new Ext.data.Connection();
+	conn = new Ext.data.Connection();
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	nameEl = Ext.get('list_name');
-
 	Element.show('ajax-indicator');
-
 	conn.request(
 	{
 		url     : 'redcase/index',
@@ -1113,7 +1146,8 @@
 {
 	choosen = Ext.get('list2_id').getValue(false);
 	conn = new Ext.data.Connection();
-
+        var csrf = Ext.select("meta[name='csrf-token']").first();
+        Ext.Ajax.defaultHeaders = Ext.apply(Ext.Ajax.defaultHeaders || {}, {'X-CSRF-Token': csrf.getAttribute('content')});
 	Element.show('ajax-indicator');
 
 	conn.request(
