use brConfig isAdmin flag to trigger QA mode.
authorrajbot <raj@archive.org>
Tue, 8 Feb 2011 23:50:40 +0000 (23:50 +0000)
committerrajbot <raj@archive.org>
Tue, 8 Feb 2011 23:50:40 +0000 (23:50 +0000)
BookReaderIA/datanode/BookReaderJSIA.php
BookReaderIA/inc/BookReader.inc

index 006ad93..816f871 100644 (file)
@@ -573,6 +573,12 @@ if (typeof(brConfig) != 'undefined') {
     } else if (brConfig['mode'] == 2) {
         br.mode = 2;      
     }
+    
+    if (typeof(brConfig["isAdmin"]) != 'undefined') {
+        br.isAdmin = brConfig["isAdmin"];
+    } else {
+        br.isAdmin = false;
+    }
 } // brConfig
 
 
@@ -635,16 +641,6 @@ OLAuth.prototype.setPopupMsg = function(msg, resolution) {
     this.popup.innerHTML = ['<p><strong>', msg, '</strong></p><p>', resolution, '</p>'].join('\n');
 }
 
-OLAuth.prototype.isAdmin = function() {
-    var isAdmin = false;
-    
-    $.ajax({url:'/bookreader/BookReaderAdmin.php?id='+br.bookId, 
-        success:function(data){isAdmin=data.isAdmin;}, 
-        async:false
-    });
-    return isAdmin;
-}
-
 OLAuth.prototype.showError = function(msg, resolution) {
    $(this.popup).css({
         backgroundColor: "#fff",
@@ -656,7 +652,7 @@ OLAuth.prototype.showError = function(msg, resolution) {
 
 OLAuth.prototype.initCallback = function(obj) {
     if (false == obj.success) {
-        if (this.isAdmin()) {
+        if (br.isAdmin) {
             ret = confirm("We couldn't authenticate your loan with Open Library, but since you are an administrator or uploader of this book, you can access this book for QA purposes. Would you like to QA this book?");
             if (!ret) {
                 this.showError(obj.msg, obj.resolution)
index 2044bf0..9f3eefc 100644 (file)
@@ -88,7 +88,7 @@ class BookReader
   // 
   // @param subprefix Optional prefix to display a book inside an item (e.g. if does not match identifier)
   public static function draw($server, $mainDir, $identifier, $subPrefix, $title,
-                              $coverLeaf=null, $titleStart='Internet Archive', $uiMode='full', $protected = false)
+                              $coverLeaf=null, $titleStart='Internet Archive', $uiMode='full', $protected = false, $isAdmin=false)
   {
     // Set title to default if not set
     if (!$title) {
@@ -190,6 +190,9 @@ class BookReader
 <? } else { ?>
   brConfig["mode"] = 2;
 <? } ?>
+<? if ($isAdmin == true) {
+     echo '  brConfig["isAdmin"] = true;';
+   } ?>   
 </script>
 <script type="text/javascript">
 // The URL in the script tag below is dynamically generated JavaScript that includes the book metadata and page image access functions.