includes/clientside/static/rank-manager.js
changeset 794 720516162012
parent 779 609e35845ec3
child 823 4596c40aaa94
--- a/includes/clientside/static/rank-manager.js	Mon Dec 22 21:26:19 2008 -0500
+++ b/includes/clientside/static/rank-manager.js	Mon Dec 22 21:54:30 2008 -0500
@@ -507,6 +507,23 @@
         {
           handle_invalid_json(ajax.responseText);
         }
+        if ( response.error )
+        {
+          if ( response.error == 'need_auth_to_admin' )
+          {
+            load_component('login');
+            var rid = rank_id;
+            ajaxDynamicReauth(function()
+              {
+                ajaxInitRankEdit(rid);
+              });
+          }
+          else
+          {
+            alert(response.error);
+          }
+          return false;
+        }
         var editor = new RankEditorControl(response);
         editor.onsubmit = ajaxRankEditHandleSaveExisting;
         editor.ondelete = ajaxRankEditHandleDelete;
@@ -609,23 +626,34 @@
         else
         {
           whitey.parentNode.removeChild(whitey);
-          miniPromptMessage({
-              title: $lang.get('acpur_err_save_failed_title'),
-              message: response.error,
-              buttons: [
-                {
-                  text: $lang.get('etc_ok'),
-                  color: 'red',
-                  style: {
-                    fontWeight: 'bold'
-                  },
-                  onclick: function()
+          if ( response.error == 'need_auth_to_admin' )
+          {
+            load_component('login');
+            ajaxDynamicReauth(function()
+              {
+                ajaxRankEditHandleSave(editor, switch_new);
+              });
+          }
+          else
+          {
+            miniPromptMessage({
+                title: $lang.get('acpur_err_save_failed_title'),
+                message: response.error,
+                buttons: [
                   {
-                    miniPromptDestroy(this);
+                    text: $lang.get('etc_ok'),
+                    color: 'red',
+                    style: {
+                      fontWeight: 'bold'
+                    },
+                    onclick: function()
+                    {
+                      miniPromptDestroy(this);
+                    }
                   }
-                }
-              ]
-          });
+                ]
+            });
+          }
         }
       }
     }, true);
@@ -733,23 +761,34 @@
         else
         {
           whitey.parentNode.removeChild(whitey);
-          miniPromptMessage({
-              title: $lang.get('acpur_err_delete_failed_title'),
-              message: response.error,
-              buttons: [
-                {
-                  text: $lang.get('etc_ok'),
-                  color: 'red',
-                  style: {
-                    fontWeight: 'bold'
-                  },
-                  onclick: function()
+          if ( response.error == 'need_auth_to_admin' )
+          {
+            load_component('login');
+            ajaxDynamicReauth(function()
+              {
+                ajaxRankEditDeleteConfirmed(editor);
+              });
+          }
+          else
+          {
+            miniPromptMessage({
+                title: $lang.get('acpur_err_delete_failed_title'),
+                message: response.error,
+                buttons: [
                   {
-                    miniPromptDestroy(this);
+                    text: $lang.get('etc_ok'),
+                    color: 'red',
+                    style: {
+                      fontWeight: 'bold'
+                    },
+                    onclick: function()
+                    {
+                      miniPromptDestroy(this);
+                    }
                   }
-                }
-              ]
-          });
+                ]
+            });
+          }
         }
       }
     }, true);