Changeset 32387


Ignore:
Timestamp:
2018-08-30T11:30:18+12:00 (6 years ago)
Author:
kjdon
Message:

removed Administration Page breadcrumb from Register and AccountSettings pages - these two are just for users, not for admin users, so don't give them link to Admin page which they can't access. Moved some code into templates to reduce the amount of duplicated code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/authen.xsl

    r32372 r32387  
    4040    <!-- set page breadcrumbs -->
    4141    <xsl:template name="breadcrumbs">
    42         <gslib:siteLink/><gslib:rightArrow/><a href="{$library_name}/admin/ListUsers"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.authentication')"/></a>
     42        <gslib:siteLink/><xsl:if test="/page/pageResponse/authenticationNode/service/@operation != 'AccountSettings' and /page/pageResponse/authenticationNode/service/@operation != 'Register'"><gslib:rightArrow/><a href="{$library_name}/admin/ListUsers"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.authentication')"/></a></xsl:if>
    4343    </xsl:template>
    4444   
     
    5353            <xsl:choose>
    5454                <!-- ********** -->
    55                 <!-- LOGIN PAGE -->
     55                <!-- LOGIN PAGE: this page is used when the user has been directed to Login by trying to access a restricted page when they are not already logged in
     56                If they click the login button, then the login.xsl is used -->
    5657                <!-- ********** -->
    5758                <xsl:when test="/page/pageResponse/authenticationNode/service/@operation = 'Login'">
     59                 
    5860                    <form method="POST" action="{$library_name}/admin/{/page/pageRequest/paramList/param[@name = 's1.authpage']/@value}">
    5961                        <table id="loginTable">
     
    273275                            </xsl:choose>                       
    274276                            <xsl:if test="/page/pageResponse/authenticationNode/service/@operation = 'EditUser'">
    275                                 <tr>
    276                                     <td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.groups')"/><xsl:text>: </xsl:text></td>
    277                                     <td>
    278                                         <input id="groupsInput" size="50" type="text" name="s1.groups" value="{/page/pageResponse/authenticationNode/service/userNodeList/userNode/@groups}"/>
    279                                     </td>
    280                                     <td>
    281                                         <select id="groupSelector">
    282                                             <option>COLLNAME-collection-editor</option>
    283                                             <option>personal-collections-editor</option>
    284                                             <option>all-collections-editor</option>
    285                                             <option>administrator</option>
    286                                         </select>
    287                                     </td>
    288                                     <td>
    289                                         <button id="addGroupButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.add_group')"/></button>
    290                                         <script type="text/javascript">
    291                                             <xsl:text disable-output-escaping="yes">
    292                                                 var addGroupButton = document.getElementById("addGroupButton");
    293                                                 addGroupButton.onclick = function()
    294                                                 {
    295                                                     var groupsInput = document.getElementById("groupsInput");
    296                                                     var groupSelector = document.getElementById("groupSelector");
    297                                                     var options = groupSelector.getElementsByTagName("OPTION");
    298                                                     var selectedGroup = options[groupSelector.selectedIndex].innerHTML;
    299                                                     var currentValue = groupsInput.value;
    300                                                    
    301                                                     if(currentValue &amp;&amp; currentValue.search(/\w/) != -1)
    302                                                     {
    303                                                         groupsInput.value = currentValue + "," + selectedGroup;
    304                                                     }
    305                                                     else
    306                                                     {
    307                                                         groupsInput.value = selectedGroup;
    308                                                     }
    309                                                     return false;
    310                                                 }
    311                                             </xsl:text>
    312                                         </script>
    313                                     </td>
    314                                 </tr>
    315                                 <tr><td colspan="4"><xsl:value-of select="util:getInterfaceText('default', /page/@lang, 'authen.group_desc')"/><ul><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.admin_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.all_coll_edit_desc')"/> </li> <li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.pers_coll_edit_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.single_coll_edit_desc')"/> </li></ul></td></tr>
     277                              <xsl:call-template name="addGroupInputField"><xsl:with-param name="default_value"><xsl:value-of select="/page/pageResponse/authenticationNode/service/userNodeList/userNode/@groups"/></xsl:with-param></xsl:call-template>
    316278                                <tr>
    317279                                    <td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.comment')"/><xsl:text>: </xsl:text></td>
     
    343305                                    <input id="submitButton" type="submit" value="{util:getInterfaceText($interface_name, /page/@lang, 'authen.submit')}"/>
    344306                                    <xsl:if test="/page/pageResponse/authenticationNode/service/@operation = 'AccountSettings'">
    345                                         <script type="text/javascript">
    346                                             <xsl:text disable-output-escaping="yes">
    347                                                 $("#submitButton").click(function()
    348                                                 {
    349                                                     var passwordOne = $("#passwordOne");
    350                                                     var passwordTwo = $("#passwordTwo");
    351                                                    
    352                                                     if(passwordOne.val() != passwordTwo.val())
    353                                                     {
    354                                                         alert("The passwords you have entered do not match");
    355                                                         return false;
    356                                                     }
    357                                                     else
    358                                                     {
    359                                                         return true;
    360                                                     }
    361                                                 });
    362                                             </xsl:text>
    363                                         </script>
     307                                      <xsl:call-template name="addPasswordCheckJavascript"/>
    364308                                    </xsl:if>
    365309                                </td>
     
    414358                            </tr>
    415359                            <xsl:if test="/page/pageResponse/authenticationNode/service/@operation = 'AddUser'">
    416                                 <tr>
    417                                     <td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.groups')"/><xsl:text>: </xsl:text></td>
    418                                     <td>
    419                                         <input id="groupsInput" size="50" type="text" name="s1.groups"/>
    420                                     </td>
    421                                     <td>
    422                                         <select id="groupSelector">
    423                                           <option>COLLNAME-collection-editor</option>
    424                                             <option>personal-collections-editor</option>
    425                                             <option>all-collections-editor</option>
    426                                             <option>administrator</option>
    427                                         </select>
    428                                     </td>
    429                                     <td>
    430                                         <button id="addGroupButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.add_group')"/></button>
    431                                         <script type="text/javascript">
    432                                             <xsl:text disable-output-escaping="yes">
    433                                                 var addGroupButton = document.getElementById("addGroupButton");
    434                                                 addGroupButton.onclick = function()
    435                                                 {
    436                                                     var groupsInput = document.getElementById("groupsInput");
    437                                                     var groupSelector = document.getElementById("groupSelector");
    438                                                     var options = groupSelector.getElementsByTagName("OPTION");
    439                                                     var selectedGroup = options[groupSelector.selectedIndex].innerHTML;
    440                                                     var currentValue = groupsInput.value;
    441                                                    
    442                                                     if(currentValue &amp;&amp; currentValue.search(/\w/) != -1)
    443                                                     {
    444                                                         groupsInput.value = currentValue + "," + selectedGroup;
    445                                                     }
    446                                                     else
    447                                                     {
    448                                                         groupsInput.value = selectedGroup;
    449                                                     }
    450                                                     return false;
    451                                                 }
    452                                             </xsl:text>
    453                                         </script>
    454                                     </td>
    455                                 </tr>
    456                                 <tr><td colspan="4"><xsl:value-of select="util:getInterfaceText('default', /page/@lang, 'authen.group_desc')"/><ul><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.admin_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.all_coll_edit_desc')"/> </li> <li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.pers_coll_edit_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.single_coll_edit_desc')"/> </li></ul></td></tr>
     360                              <xsl:call-template name="addGroupInputField"/>
    457361                                <tr>
    458362                                    <td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.comment')"/><xsl:text>: </xsl:text></td>
     
    469373                                </tr>
    470374                            </xsl:if>
    471                             <tr>
    472                               <td colspan="2">
    473                             <div class="g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"><xsl:text> </xsl:text></div></td></tr>
     375                            <xsl:call-template name="addRecaptcha">
     376                              <xsl:with-param name="formName">registerForm</xsl:with-param>
     377                            </xsl:call-template>
    474378                            <tr>
    475379                              <td>
    476                                 <!-- need to add s1. to the name of g-recaptcha-response, so that it gets passed to the service -->
    477                                   <script type="text/javascript">
    478                                     <xsl:text disable-output-escaping="yes">
    479                                         $( "#registerForm").submit(function( event ) {
    480                                         var captchaelem = $("#g-recaptcha-response");
    481                                         captchaelem.attr("name", "s1.g-recaptcha-response");
    482                                         return true;
    483                                         });
    484                                        
    485                                         </xsl:text>
    486                                     </script>
    487                                     <input id="submitButton" type="submit" value="{util:getInterfaceText($interface_name, /page/@lang, 'authen.submit')}"/>
    488                                 </td>
     380                                <input id="submitButton" type="submit" value="{util:getInterfaceText($interface_name, /page/@lang, 'authen.submit')}"/>
     381                                <xsl:call-template name="addPasswordCheckJavascript"/>
     382                              </td>
    489383                            </tr>
    490384                        </table>
     
    515409            </xsl:choose>
    516410        </div>
    517     </xsl:template>
    518    
     411          </xsl:template>
     412
     413          <xsl:template name="addGroupInputField">
     414        <xsl:param name="default_value"/>
     415        <tr>
     416          <td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.groups')"/><xsl:text>: </xsl:text></td>
     417          <td>
     418            <input id="groupsInput" size="50" type="text" name="s1.groups" value="{$default_value}"/>
     419          </td>
     420          <td>
     421            <select id="groupSelector">
     422              <option>COLLNAME-collection-editor</option>
     423              <option>personal-collections-editor</option>
     424              <option>all-collections-editor</option>
     425              <option>administrator</option>
     426            </select>
     427          </td>
     428          <td>
     429            <button id="addGroupButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.add_group')"/></button>
     430            <script type="text/javascript">
     431              <xsl:text disable-output-escaping="yes">
     432            var addGroupButton = document.getElementById("addGroupButton");
     433            addGroupButton.onclick = function()
     434            {
     435            var groupsInput = document.getElementById("groupsInput");
     436            var groupSelector = document.getElementById("groupSelector");
     437            var options = groupSelector.getElementsByTagName("OPTION");
     438            var selectedGroup = options[groupSelector.selectedIndex].innerHTML;
     439            var currentValue = groupsInput.value;
     440           
     441            if(currentValue &amp;&amp; currentValue.search(/\w/) != -1)
     442            {
     443            groupsInput.value = currentValue + "," + selectedGroup;
     444            }
     445            else
     446            {
     447            groupsInput.value = selectedGroup;
     448            }
     449            return false;
     450            }
     451              </xsl:text>
     452            </script>
     453          </td>
     454        </tr>
     455        <tr><td colspan="4"><xsl:value-of select="util:getInterfaceText('default', /page/@lang, 'authen.group_desc')"/><ul><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.admin_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.all_coll_edit_desc')"/> </li> <li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.pers_coll_edit_desc')"/></li><li><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.single_coll_edit_desc')"/> </li></ul></td></tr>
     456
     457          </xsl:template>
     458         
     459          <xsl:template name="addPasswordCheckJavascript">
     460        <script type="text/javascript">
     461          <xsl:text disable-output-escaping="yes">
     462            $("#submitButton").click(function()
     463            {
     464              var passwordOne = $("#passwordOne");
     465              var passwordTwo = $("#passwordTwo");
     466           
     467              if(passwordOne.val() != passwordTwo.val())
     468              {
     469                alert("The passwords you have entered do not match");
     470                return false;
     471              }
     472              else
     473              {
     474                return true;
     475              }
     476            });
     477          </xsl:text>
     478        </script>
     479       
     480          </xsl:template>
     481
     482          <!-- adds in recaptcha box if the recaptcha_key attribute is set for authenticationNode/service - this is determined by operations element in Authentication serviceRack -->
     483          <xsl:template name="addRecaptcha">
     484        <xsl:param name="formName"/>
     485        <xsl:variable name="recaptcha_key"><xsl:value-of select="/page/pageResponse/authenticationNode/service/@recaptcha_key"/></xsl:variable>
     486        <xsl:if test="$recaptcha_key">
     487        <tr>
     488          <td colspan="2">
     489            <div class="g-recaptcha" data-sitekey="{$recaptcha_key}"><xsl:text> </xsl:text></div>
     490            <!-- need to add s1. to the name of g-recaptcha-response, so that it gets passed to the service -->
     491            <script type="text/javascript">
     492              <xsl:text disable-output-escaping="yes">
     493            $( "#</xsl:text><xsl:value-of select="$formName"/><xsl:text disable-output-escaping="yes">").submit(function( event ) {
     494            var captchaelem = $("#g-recaptcha-response");
     495            captchaelem.attr("name", "s1.g-recaptcha-response");
     496            return true;
     497            });
     498           
     499              </xsl:text>
     500            </script>
     501        </td></tr>
     502        </xsl:if>
     503          </xsl:template>
    519504</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.