<commit_before><!--
The MIT License

Copyright (c) 2004-2009, Sun Microsystems, Inc., <NAME>, <NAME>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
  <f:block xmlns:local="local">
    <j:set var="groups" value="${descriptor.allGroups}"/>
    <d:taglib uri="local">
      <!-- generate one row for the sid name @sid -->
      <d:tag name="row">
        <td class="left-most">${title}</td>
        <j:forEach var="g" items="${groups}">
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <td width="*">
                <f:checkbox name="[${p.id}]" checked="${instance.hasExplicitPermission(attrs.sid,p)}"/>
              </td>
            </j:if>
          </j:forEach>
        </j:forEach>
        <td class="stop">
          <j:if test="${attrs.sid!='anonymous'}">
            <a href="#">
              <img alt="remove" src="${imagesURL}/16x16/stop.gif" height="16" width="16"/>
            </a>
          </j:if>
        </td>
      </d:tag>
    </d:taglib>
    <link rel="stylesheet" href="${rootURL}${app.VIEW_RESOURCE_PATH}/hudson/security/table.css" type="text/css" />
    <j:set var="strategyid" value="${descriptor.jsonSafeClassName}" />
    <table id="${strategyid}" class="center-align global-matrix-authorization-strategy-table" name="data">

      <!-- The first row will show grouping -->
      <tr class="group-row">
        <td rowspan="2" class="pane-header blank">
          ${%User/group}
        </td>
        <j:forEach var="g" items="${groups}">
          <j:set var="cnt" value="${0}" />
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <j:set var="cnt" value="${cnt+1}"/>
            </j:if>
          </j:forEach>

          <td class="pane-header" colspan="${cnt}">
            ${g.title}
          </td>
        </j:forEach>
        <td rowspan="2" class="stop" />
      </tr>
      <!-- The second row for individual permission -->
      <tr class="caption-row">
        <j:forEach var="g" items="${groups}">
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <th class="pane" tooltip="${p.description}">
                ${p.name}
              </th>
            </j:if>
          </j:forEach>
        </j:forEach>
      </tr>

      <j:forEach var="sid" items="${instance.allSIDs}">
        <tr name="[${sid}]" class="permission-row">
          <local:row title="${sid}" sid="${sid}"/>
        </tr>
      </j:forEach>
      <tr name="anonymous">
        <local:row sid="anonymous" title="${%Anonymous}" />
      </tr>


      <!-- template row to be used for adding a new row -->
      <j:set var="id" value="${h.generateId()}"/>
      <tr id="${id}" style="display:none" class="permission-row">
        <local:row sid="${null}" />
      </tr>
    </table>
    <table style="margin-top:0.5em; margin-left: 2em; width: 100%">
     <tr><td colspan="3">
      ${%User/group to add}:
      <input type="text" id="${id}text" />
      <input type="button" value="${%Add}" id="${id}button"/>
     </td><td align="right">
      <a href="#" class="help-button" helpURL="${rootURL}${descriptor.find('hudson.security.GlobalMatrixAuthorizationStrategy$DescriptorImpl').getHelpFile('user-group')}"><img src="${imagesURL}/16x16/help.gif" alt="[help]" height="16" width="16"/></a>
     </td></tr>
     <f:helpArea />
    </table>
    <script>
      (function() {
        <!-- place master outside the DOM tree so that it won't creep into the submitted form -->
        var master = document.getElementById('${id}');
        var table = master.parentNode;
        table.removeChild(master);
      
        makeButton($$('${id}button'), function (e) {
          <!-- when 'add' is clicked... -->
          var name = $$('${id}text').value;
          if(name=="") {
            alert("Please enter a user name or a group name");
            return;
          }
          if(findElementsBySelector(table,"TR").find(function(n){return n.getAttribute("name")=='['+name+']';})!=null) {
            alert("Entry for '"+name+"' already exists");
            return;
          }

          if(document.importNode!=null)
            copy = document.importNode(master,true);
          else
            copy = master.cloneNode(true); <!-- for IE -->
          copy.removeAttribute("id");
          copy.removeAttribute("style");
          copy.firstChild.innerHTML = name;
          copy.setAttribute("name",'['+name+']');
          table.appendChild(copy);
          Behaviour.applySubtree(findAncestor(table,"TABLE"),true);
        });
      })();

      Behaviour.register({
        "#${strategyid} TD.stop A" : function(e) {
          e.onclick = function() {
            var tr = findAncestor(this,"TR");
            tr.parentNode.removeChild(tr);
            return false;
          }
          e = null; <!-- avoid memory leak -->
        },
        <j:if test="${empty(descriptorPath)}">
          <j:set var="descriptorPath" value="${rootURL}${descriptor.descriptorFullUrl}"/>
        </j:if>
        <!-- validates the name -->
        "#${strategyid} TR.permission-row" : function(e) {
          FormChecker.delayedCheck("${descriptorPath}/checkName?value="+encodeURIComponent(e.getAttribute("name")),"GET",e.firstChild);
        }
      });
    </script>
  </f:block>
</j:jelly>
<commit_msg>[FIXED JENKINS-9347] descriptorFullUrl already has context root, so don't preprend ${rootURL} .. thx alexlehm<commit_after><!--
The MIT License

Copyright (c) 2004-2011, Sun Microsystems, Inc., <NAME>, <NAME>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
  <f:block xmlns:local="local">
    <j:set var="groups" value="${descriptor.allGroups}"/>
    <d:taglib uri="local">
      <!-- generate one row for the sid name @sid -->
      <d:tag name="row">
        <td class="left-most">${title}</td>
        <j:forEach var="g" items="${groups}">
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <td width="*">
                <f:checkbox name="[${p.id}]" checked="${instance.hasExplicitPermission(attrs.sid,p)}"/>
              </td>
            </j:if>
          </j:forEach>
        </j:forEach>
        <td class="stop">
          <j:if test="${attrs.sid!='anonymous'}">
            <a href="#">
              <img alt="remove" src="${imagesURL}/16x16/stop.gif" height="16" width="16"/>
            </a>
          </j:if>
        </td>
      </d:tag>
    </d:taglib>
    <link rel="stylesheet" href="${rootURL}${app.VIEW_RESOURCE_PATH}/hudson/security/table.css" type="text/css" />
    <j:set var="strategyid" value="${descriptor.jsonSafeClassName}" />
    <table id="${strategyid}" class="center-align global-matrix-authorization-strategy-table" name="data">

      <!-- The first row will show grouping -->
      <tr class="group-row">
        <td rowspan="2" class="pane-header blank">
          ${%User/group}
        </td>
        <j:forEach var="g" items="${groups}">
          <j:set var="cnt" value="${0}" />
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <j:set var="cnt" value="${cnt+1}"/>
            </j:if>
          </j:forEach>

          <td class="pane-header" colspan="${cnt}">
            ${g.title}
          </td>
        </j:forEach>
        <td rowspan="2" class="stop" />
      </tr>
      <!-- The second row for individual permission -->
      <tr class="caption-row">
        <j:forEach var="g" items="${groups}">
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <th class="pane" tooltip="${p.description}">
                ${p.name}
              </th>
            </j:if>
          </j:forEach>
        </j:forEach>
      </tr>

      <j:forEach var="sid" items="${instance.allSIDs}">
        <tr name="[${sid}]" class="permission-row">
          <local:row title="${sid}" sid="${sid}"/>
        </tr>
      </j:forEach>
      <tr name="anonymous">
        <local:row sid="anonymous" title="${%Anonymous}" />
      </tr>


      <!-- template row to be used for adding a new row -->
      <j:set var="id" value="${h.generateId()}"/>
      <tr id="${id}" style="display:none" class="permission-row">
        <local:row sid="${null}" />
      </tr>
    </table>
    <table style="margin-top:0.5em; margin-left: 2em; width: 100%">
     <tr><td colspan="3">
      ${%User/group to add}:
      <input type="text" id="${id}text" />
      <input type="button" value="${%Add}" id="${id}button"/>
     </td><td align="right">
      <a href="#" class="help-button" helpURL="${rootURL}${descriptor.find('hudson.security.GlobalMatrixAuthorizationStrategy$DescriptorImpl').getHelpFile('user-group')}"><img src="${imagesURL}/16x16/help.gif" alt="[help]" height="16" width="16"/></a>
     </td></tr>
     <f:helpArea />
    </table>
    <script>
      (function() {
        <!-- place master outside the DOM tree so that it won't creep into the submitted form -->
        var master = document.getElementById('${id}');
        var table = master.parentNode;
        table.removeChild(master);
      
        makeButton($$('${id}button'), function (e) {
          <!-- when 'add' is clicked... -->
          var name = $$('${id}text').value;
          if(name=="") {
            alert("Please enter a user name or a group name");
            return;
          }
          if(findElementsBySelector(table,"TR").find(function(n){return n.getAttribute("name")=='['+name+']';})!=null) {
            alert("Entry for '"+name+"' already exists");
            return;
          }

          if(document.importNode!=null)
            copy = document.importNode(master,true);
          else
            copy = master.cloneNode(true); <!-- for IE -->
          copy.removeAttribute("id");
          copy.removeAttribute("style");
          copy.firstChild.innerHTML = name;
          copy.setAttribute("name",'['+name+']');
          table.appendChild(copy);
          Behaviour.applySubtree(findAncestor(table,"TABLE"),true);
        });
      })();

      Behaviour.register({
        "#${strategyid} TD.stop A" : function(e) {
          e.onclick = function() {
            var tr = findAncestor(this,"TR");
            tr.parentNode.removeChild(tr);
            return false;
          }
          e = null; <!-- avoid memory leak -->
        },
        <j:if test="${empty(descriptorPath)}">
          <j:set var="descriptorPath" value="${descriptor.descriptorFullUrl}"/>
        </j:if>
        <!-- validates the name -->
        "#${strategyid} TR.permission-row" : function(e) {
          FormChecker.delayedCheck("${descriptorPath}/checkName?value="+encodeURIComponent(e.getAttribute("name")),"GET",e.firstChild);
        }
      });
    </script>
  </f:block>
</j:jelly>

{'fraction_non_alphanumeric': 0.17842574407010123, 'fraction_numerical': 0.005589968273153044, 'mean_word_length': 2.574244060475162, 'pattern_counts': {'":': 0, '<': 202, '<?xml version=': 0, '>': 202, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5632587', 'n_tokens_mistral': 4005, 'n_tokens_neox': 3895, 'n_words': 976}