Changeset 1449

Show
Ignore:
Timestamp:
07/02/07 14:34:01
Author:
douglm
Message:

Further javascript changes for acls.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl

    r1445 r1449  
    356356    <script type="text/javascript" src="{$resourcesRoot}/resources/bedework.js">&#160;</script> 
    357357    <xsl:if test="/bedework/page='modSchedulingPrefs' or 
    358                   /bedework/page='modPrefs' or  
     358                  /bedework/page='modPrefs' or 
    359359                  /bedework/page='attendeeRespond'"> 
    360360      <script type="text/javascript" src="{$resourcesRoot}/resources/bedeworkPrefs.js">&#160;</script> 
     
    30233023      <div id="sharingBox"> 
    30243024        <xsl:choose> 
    3025           <xsl:when test="/bedework/editableAccess/access/acl">  
     3025          <xsl:when test="/bedework/editableAccess/access/acl"> 
    30263026            <xsl:apply-templates select="/bedework/editableAccess/access/acl" mode="currentAccess"> 
    30273027              <xsl:with-param name="action" select="$event-setAccess"/> 
     
    30293029              <xsl:with-param name="guid" select="$guid"/> 
    30303030              <xsl:with-param name="recurrenceId" select="$recurrenceId"/> 
    3031               <xsl:with-param name="method">2</xsl:with-param>  
     3031              <xsl:with-param name="method">2</xsl:with-param> 
    30323032            </xsl:apply-templates> 
    30333033          </xsl:when> 
     
    70127012            Rights: 
    70137013          </h5> 
    7014           <input type="hidden" name="how" value=""/> 
     7014          <input type="hidden" name="how" value="" id="bwCurrentHow"/> 
    70157015          <!-- field 'acl' will receive xml for method 2 --> 
    7016           <input type="hidden" name="acl" value=""/>  
     7016          <input type="hidden" name="acl" value="" id="bwCurrentAcl" /> 
    70177017          <!-- Advanced Access Rights: --> 
    70187018          <!-- the "how" field is set by iterating over the howItems below --> 
     
    72647264    <xsl:param name="recurrenceId"/> <!-- optional (for entities) --> 
    72657265    <xsl:param name="what"/> <!-- optional (for scheduling only) --> 
    7266     <xsl:param name="method">1</xsl:param> <!-- which method of access control  
    7267       are we using: 1 (one request per pricipal) or 2 (set all with  
    7268       javascript and send entire ACL to server) -->   
     7266    <xsl:param name="method">1</xsl:param> <!-- which method of access control 
     7267      are we using: 1 (one request per pricipal) or 2 (set all with 
     7268      javascript and send entire ACL to server) --> 
    72697269    <h3>Current Access:</h3> 
    72707270    <table class="common scheduling" id="bwCurrentAccess"> 
     
    73927392    </table> 
    73937393  </xsl:template> 
    7394    
     7394 
    73957395  <!--==== SEARCH RESULT ====--> 
    73967396  <xsl:template name="searchResult"> 
     
    76897689  </xsl:template> 
    76907690 
    7691   <xsl:template name="grantDenyToInternal"><!--  
    7692   --><xsl:param name="name"/><!--  
     7691  <xsl:template name="grantDenyToInternal"><!-- 
     7692  --><xsl:param name="name"/><!-- 
    76937693  --><xsl:choose> 
    76947694       <xsl:when test="$name = 'all'">A</xsl:when> 
     
    77057705       <xsl:when test="$name = 'schedule-request'">t</xsl:when> 
    77067706       <xsl:when test="$name = 'schedule-reply'">y</xsl:when> 
    7707        <xsl:when test="$name = 'schedule-free-busy'">s</xsl:when>        
     7707       <xsl:when test="$name = 'schedule-free-busy'">s</xsl:when> 
    77087708       <xsl:when test="$name = 'unbind'">u</xsl:when> 
    77097709       <xsl:when test="$name = 'unlock'">U</xsl:when> 
     
    77337733    </xsl:choose> 
    77347734  </xsl:template> 
    7735    
     7735 
    77367736  <!--==== FOOTER ====--> 
    77377737  <xsl:template name="footer"> 
  • trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkAccess.js

    r1448 r1449  
    5151var ownerStr = "owner"; 
    5252var otherStr = "other"; 
    53 var deleteStr = "remove"; 
    5453var grantStr = "grant"; 
     54 
     55var deleteStr = "default"; 
    5556 
    5657// How granted accesses appear 
     
    290291 */ 
    291292function bwPrincipal(who, whoType) { 
    292   this.who = who; 
    293293  this.whoType = whoType; 
    294294 
    295   // Don't touch email like addresses 
    296   if (who.indexOf("@") < 0) { 
    297     // Normalize the who 
    298     if (whoType == "user") { 
    299       if (who.indexOf(principalPrefix) != "0") { 
    300         who = userPrincipalPrefix + who; 
    301       } 
    302     } else if (whoType == "group") { 
    303       if (who.indexOf(principalPrefix) != "0") { 
    304         who = groupPrincipalPrefix + who; 
    305       } 
    306     } else if (whoType == "resource") { 
    307       if (who.indexOf(principalPrefix) != "0") { 
    308         who = resourcePrincipalPrefix + who; 
     295  if ((whoType == "auth") || 
     296      (whoType == "unauth") || 
     297      (whoType == "owner") || 
     298      (whoType == "other")) { 
     299    // Don't set who 
     300  } else { 
     301    this.who = who; 
     302 
     303    // Don't touch email like addresses 
     304    if (who.indexOf("@") < 0) { 
     305      // Normalize the who 
     306      if (whoType == "user") { 
     307        if (who.indexOf(principalPrefix) != "0") { 
     308          who = userPrincipalPrefix + who; 
     309        } 
     310      } else if (whoType == "group") { 
     311        if (who.indexOf(principalPrefix) != "0") { 
     312          who = groupPrincipalPrefix + who; 
     313        } 
     314      } else if (whoType == "resource") { 
     315        if (who.indexOf(principalPrefix) != "0") { 
     316          who = resourcePrincipalPrefix + who; 
     317        } 
    309318      } 
    310319    } 
     
    368377  } 
    369378 
     379  this.toString = function() { 
     380    return "bwPrincipal[who=" + this.who + ", whoType=" + this.whoType + "]"; 
     381  } 
     382 
    370383  this.equals = function(pr) { 
     384    //alert("this=" + this.toString() + " pr=" + pr.toString()); 
     385 
    371386    if (this.whoType != pr.whoType) { 
    372387      return false; 
     
    480495  } 
    481496 
    482   this.toFormRow = function(row) { 
     497  this.toFormRow = function(row, aceI) { 
    483498    row.insertCell(0).appendChild(document.createTextNode(this.principal.format())); 
    484499    row.insertCell(1).appendChild(document.createTextNode(this.formatHow())); 
    485500    row.insertCell(2).appendChild(document.createTextNode(this.formatInherited())); 
    486501    var td_3 = row.insertCell(3); 
    487     td_3.appendChild(document.createTextNode('')); 
    488     //<a href="javascript:bwAcl.delete(' + j +')">' + deleteStr + '</a> 
     502    if (this.inherited == "") { 
     503      td_3.innerHTML = "<a href=\"javascript:bwAcl.deleteAce('" + aceI + "')\">" + deleteStr + "</a>"; 
     504    } 
    489505  } 
    490506} 
     
    495511  var aces = new Array(); 
    496512 
     513  /* If we delete an ace we need to reinstate any inherited access for the same principal 
     514   */ 
     515  var savedInherited = new Array(); 
     516 
    497517  // Initialize the list. 
    498518  // The function expects a comma-separated list of arguments grouped 
    499519  // into the five ACE properties. 
    500520  this.init = function(who, whoType, how, inherited, invert) { 
    501     aces.push(new bwAce(who, whoType, how, inherited, invert)); 
     521    var newAce = new bwAce(who, whoType, how, inherited, invert); 
     522    aces.push(newAce); 
     523    if (inherited != "") { 
     524      savedInherited.push(newAce); 
     525    } 
    502526  } 
    503527 
     
    505529  this.addAce = function(newAce) { 
    506530    // expects a bwAce object as parameter 
    507     for (i = 0; i < aces.length; i++) { 
     531    for (var i = 0; i < aces.length; i++) { 
    508532      if (aces[i].equals(newAce)) { 
    509533        // replace an existing ace 
     
    539563    //       "\ntype= " + type + "\nhow=" + how); 
    540564 
    541     bwAcl.addAce(new bwAce(formObj.who.value, type, how, "" , false)); 
     565    this.addAce(new bwAce(formObj.who.value, type, how, "" , false)); 
    542566    formObj.who.value = ""; 
    543567 
    544568    // update the acl form field 
    545     formObj.acl.value = this.toXml(); 
     569    var formAcl = document.getElementById("bwCurrentAcl"); 
     570    formAcl.value = this.toXml(); 
    546571 
    547572    // redraw the display 
     
    550575 
    551576  this.deleteAce = function(index) { 
    552     bwAcl.aces.splice(index, 1); 
     577    var ace = aces[index]; 
     578    var replace = false; 
     579 
     580    for (var si = 0; si < savedInherited.length; si++) { 
     581      if (savedInherited[si].equals(ace)) { 
     582        ace = savedInherited[si]; 
     583        replace = true; 
     584        break; 
     585      } 
     586    } 
     587 
     588    if (replace) { 
     589      aces[index] = ace; 
     590    } else { 
     591      aces.splice(index, 1); 
     592    } 
    553593 
    554594    // update the acl form field 
    555     formObj.acl = this.toXml(); 
     595    var formAcl = document.getElementById("bwCurrentAcl"); 
     596    formAcl.value = this.toXml(); 
    556597 
    557598    // redraw the display 
     
    575616        var tr = aclTableBody.insertRow(j); 
    576617 
    577         curAce.toFormRow(tr); 
     618        curAce.toFormRow(tr, j); 
    578619      } 
    579620    } catch (e) {