Changeset 32473

Show
Ignore:
Timestamp:
18.09.2018 15:52:17 (9 months ago)
Author:
kjdon
Message:

AllowDocumentEditing? is true by default. Also, if we disable edit mode, then if we were currently in edit mode, then add docEdit=0 & ed=0 to url to take us out of editing.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl

    r32470 r32473  
    2424  </xsl:variable> 
    2525 
    26   <!-- does this collection have editing turned on --> 
     26  <!-- does this collection have editing turned on - turned on by default, can turn off in config file--> 
    2727  <xsl:variable name="isEditingTurnedOn"> 
    28     <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='AllowDocumentEditing']/@value='true'">1</xsl:if> 
     28    <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='AllowDocumentEditing']) or /page/pageResponse/format[@type='display']/gsf:option[@name='AllowDocumentEditing']/@value='true'">1</xsl:if> 
    2929  </xsl:variable> 
    3030  <!-- is editing available for the collection? eg is there an archives folder? --> 
    31   <xsl:variable name="isEditingAvailable">1</xsl:variable> 
     31  <xsl:variable name="isEditingAvailable"> 
     32  <xsl:choose><xsl:when test="/page/pageResponse/collection/@no_archives">0</xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose></xsl:variable> 
    3233  <!-- is a user logged in, and do they have editing rights for this collection? --> 
    3334  <xsl:variable name="userHasEditPermission"> 
     
    386387    button.data("userMenu", menu); 
    387388 
     389    // get the base url 
     390    var url = document.URL; 
     391    var hasQueryString = (url.indexOf("?") != -1); 
     392    var hashIndex = url.indexOf("#"); 
     393     
     394    var hashPart; 
     395    if(hashIndex != -1) 
     396    { 
     397    hashPart = url.substring(hashIndex); 
     398    url = url.substring(0, hashIndex); 
     399    } 
     400 
    388401    var settingsLink = $("&lt;a&gt;") 
    389402    .attr("href", gs.xsltParams.library_name + "/admin/AccountSettings?s1.username=</xsl:text><xsl:value-of select="/page/pageRequest/userInformation/@username"/><xsl:text disable-output-escaping="yes">"); 
     
    406419    .click(function() 
    407420    { 
    408     var url = gs.xsltParams.library_name + "?a=g&amp;rt=ro&amp;s=ChangeUserEditMode&amp;s1.username=" + gs.userInformation.username + "&amp;s1.enabled=" + ((gs.userInformation.editEnabled == "true") ? "false" : "true"); 
    409     $.ajax(url) 
     421    var c_url = gs.xsltParams.library_name + "?a=g&amp;rt=ro&amp;s=ChangeUserEditMode&amp;s1.username=" + gs.userInformation.username + "&amp;s1.enabled=" + ((gs.userInformation.editEnabled == "true") ? "false" : "true"); 
     422    $.ajax(c_url) 
    410423    .success(function(response) 
    411424    { 
    412     location.reload(true); 
     425    //location.reload(true); // need to set docEdit=0 if we have just disabled editing 
     426    location.href= url + (hasQueryString ? "&amp;" : "?") + ((gs.userInformation.editEnabled == "true") ? "docEdit=0&amp;ed=0":"") + (hashPart ? hashPart : ""); 
    413427    }); 
    414428    }); 
     
    425439    menu.append(editingLink); 
    426440      </xsl:text></xsl:if><xsl:text disable-output-escaping="yes"> 
    427     var url = document.URL; 
    428     var hasQueryString = (url.indexOf("?") != -1); 
    429     var hashIndex = url.indexOf("#"); 
    430      
    431     var hashPart; 
    432     if(hashIndex != -1) 
    433     { 
    434     hashPart = url.substring(hashIndex); 
    435     url = url.substring(0, hashIndex); 
    436     } 
    437441     
    438442    var logoutLink = $("&lt;a&gt;")