Changeset 2077
- Timestamp:
- 02/26/09 17:50:04
- Files:
-
- trunk/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl (modified) (5 diffs)
- trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkAccess.js (modified) (11 diffs)
- trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkEventForm.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl
r2076 r2077 402 402 <script type="text/javascript" src="{$resourcesRoot}/resources/bedeworkPrefs.js"> </script> 403 403 </xsl:if> 404 <xsl:if test="/bedework/page='modCalendar'"> 404 <xsl:if test="/bedework/page='modCalendar' or 405 /bedework/page='modSchedulingPrefs'"> 405 406 <script type="text/javascript" src="{$resourcesRoot}/resources/bedeworkAccess.js"> </script> 406 407 <!-- initialize calendar acls, if present --> … … 7767 7768 <xsl:template name="entityAccessForm"> 7768 7769 <xsl:param name="type"/><!-- optional: currently used for inbox and outbox to conditionally display scheduling access --> 7769 <xsl:param name="method">2</xsl:param><!-- optional: 7770 there are two methods of setting access 7771 - method 1, the older method, uses a single request/response per principal 7772 - method 2 constructs a javascript object that commits the entire ACL 7773 structure in a single request 7774 Both methods are currently supported. Method two is now the default. --> 7775 <xsl:param name="acl"/><!-- nodeset of entity acls used to initialize 7776 javascript object. Required for method two. --> 7770 <xsl:param name="acl"/><!-- required: nodeset of entity acls used to initialize javascript object. --> 7771 <xsl:param name="outputId"/><!-- required: id of the current access block display to update --> 7777 7772 7778 7773 <table cellpadding="0" id="shareFormTable" class="common"> … … 7794 7789 <input type="radio" value="all" name="whoType"/> all users 7795 7790 </p> 7796 <xsl:choose> 7797 <xsl:when test="$method = '2'"> 7798 <input type="button" name="updateACLs" value="add entry" onclick="bwAcl.update(this.form)"/> 7799 </xsl:when> 7800 <xsl:otherwise> 7801 <input type="submit" name="submit" value="update access"/> 7802 </xsl:otherwise> 7803 </xsl:choose> 7791 <input type="button" name="updateACLs" value="add entry" onclick="bwAcl.update(this.form,${id})"/> 7804 7792 </div> 7805 7793 </td> … … 8030 8018 8031 8019 <xsl:template match="acl" mode="currentAccess"> 8032 <xsl:param name="action"/> <!-- required -->8033 <xsl:param name="calPathEncoded"/> <!-- optional (for entities) -->8034 <xsl:param name="guid"/> <!-- optional (for entities) -->8035 <xsl:param name="recurrenceId"/> <!-- optional (for entities) -->8036 <xsl:param name="what"/> <!-- optional (for scheduling only) -->8037 <xsl:param name="method">2</xsl:param> <!-- which method of access control8038 are we using: 1 (one request per pricipal) or 2 (set all with8039 javascript and send entire ACL to server) -->8040 8020 <h3>Current Access:</h3> 8041 <table class="common scheduling" id="bwCurrentAccess"> 8042 <thead> 8043 <tr> 8044 <th>Entry</th> 8045 <th>Access</th> 8046 <th>Inherited from</th> 8047 <th></th> 8048 </tr> 8049 </thead> 8050 <tbody> 8051 <xsl:for-each select="ace"> 8052 <xsl:variable name="who"> 8053 <xsl:choose> 8054 <xsl:when test="invert"> 8055 <xsl:choose> 8056 <xsl:when test="invert/principal/href"><xsl:value-of select="normalize-space(invert/principal/href)"/></xsl:when> 8057 <xsl:when test="invert/principal/property"><xsl:value-of select="name(invert/principal/property/*)"/></xsl:when> 8058 <xsl:otherwise><xsl:value-of select="name(invert/principal/*)"/></xsl:otherwise> 8059 </xsl:choose> 8060 </xsl:when> 8061 <xsl:otherwise> 8062 <xsl:choose> 8063 <xsl:when test="principal/href"><xsl:value-of select="normalize-space(principal/href)"/></xsl:when> 8064 <xsl:when test="principal/property"><xsl:value-of select="name(principal/property/*)"/></xsl:when> 8065 <xsl:otherwise><xsl:value-of select="name(principal/*)"/></xsl:otherwise> 8066 </xsl:choose> 8067 </xsl:otherwise> 8068 </xsl:choose> 8069 </xsl:variable> 8070 <xsl:variable name="whoType"> 8071 <xsl:choose> 8072 <xsl:when test="contains($who,/bedework/syspars/userPrincipalRoot)">user</xsl:when> 8073 <xsl:when test="contains($who,/bedework/syspars/groupPrincipalRoot)">group</xsl:when> 8074 <xsl:when test="$who='authenticated'">auth</xsl:when> 8075 <xsl:when test="$who='unauthenticated'">unauth</xsl:when> 8076 <xsl:when test="$who='all'">all</xsl:when> 8077 <xsl:when test="invert/principal/property/owner">other</xsl:when> 8078 <xsl:when test="principal/property"><xsl:value-of select="name(principal/property/*)"/></xsl:when> 8079 <xsl:when test="invert/principal/property"><xsl:value-of select="name(invert/principal/property/*)"/></xsl:when> 8080 <xsl:otherwise></xsl:otherwise> 8081 </xsl:choose> 8082 </xsl:variable> 8083 <xsl:variable name="shortWho"> 8084 <xsl:choose> 8085 <xsl:when test="$whoType='user'"><xsl:value-of select="substring-after(substring-after($who,normalize-space(/bedework/syspars/userPrincipalRoot)),'/')"/></xsl:when> 8086 <xsl:when test="$whoType='group'"><xsl:value-of select="substring-after(substring-after($who,normalize-space(/bedework/syspars/groupPrincipalRoot)),'/')"/></xsl:when> 8087 <xsl:otherwise></xsl:otherwise> <!-- if not user or group, send no who --> 8088 </xsl:choose> 8089 </xsl:variable> 8090 <tr> 8091 <td> 8092 <xsl:choose> 8093 <xsl:when test="$whoType = 'user' or ($who = 'owner' and $whoType != 'other')"> 8094 <img src="{$resourcesRoot}/resources/userIcon.gif" width="13" height="13" border="0" alt="user"/> 8095 </xsl:when> 8096 <xsl:otherwise> 8097 <img src="{$resourcesRoot}/resources/groupIcon.gif" width="13" height="13" border="0" alt="group"/> 8098 </xsl:otherwise> 8099 </xsl:choose> 8100 <xsl:text> </xsl:text> 8101 <xsl:choose> 8102 <xsl:when test="$whoType = 'other'"> 8103 anyone (other) 8104 </xsl:when> 8105 <xsl:when test="$shortWho != ''"> 8106 <xsl:value-of select="$shortWho"/> 8107 </xsl:when> 8108 <xsl:otherwise> 8109 <xsl:value-of select="$who"/> 8110 </xsl:otherwise> 8111 </xsl:choose> 8112 </td> 8113 <td class="acls"> 8114 <xsl:if test="grant"> 8115 <span class="grant"> 8116 <xsl:for-each select="grant/privilege/*"> 8117 <xsl:value-of select="name(.)"/> 8118 <xsl:if test="position() != last()">, </xsl:if> 8119 </xsl:for-each> 8120 </span><br/> 8121 </xsl:if> 8122 <xsl:if test="deny"> 8123 <span class="deny"> 8124 <xsl:for-each select="deny/privilege/*"> 8125 not-<xsl:value-of select="name(.)"/> 8126 <xsl:if test="position() != last()">, </xsl:if> 8127 </xsl:for-each> 8128 </span> 8129 </xsl:if> 8130 </td> 8131 <td> 8132 <xsl:choose> 8133 <xsl:when test="inherited"> 8134 <xsl:value-of select="inherited/href"/> 8135 </xsl:when> 8136 <xsl:otherwise> 8137 Not inherited 8138 </xsl:otherwise> 8139 </xsl:choose> 8140 </td> 8141 <td> 8142 <xsl:if test="not(inherited)"> 8143 <xsl:choose> 8144 <xsl:when test="$method = '2'"> 8145 <!-- we are using javascript to update the form --> 8146 <xsl:variable name="rowPos" select="position()-1"/> 8147 <a href="javascript:bwAcl.deleteAce({$rowPos})" title="reset to default"> 8148 <img src="{$resourcesRoot}/resources/trashIcon.gif" width="13" height="13" border="0" alt="reset to default"/> 8149 </a> 8150 </xsl:when> 8151 <xsl:otherwise> 8152 <a href="{$action}&how=default&what={$what}&who={$shortWho}&whoType={$whoType}&calPath={$calPathEncoded}&guid={$guid}&recurrenceId={$recurrenceId}" title="reset to default"> 8153 <img src="{$resourcesRoot}/resources/trashIcon.gif" width="13" height="13" border="0" alt="reset to default"/> 8154 </a> 8155 </xsl:otherwise> 8156 </xsl:choose> 8157 </xsl:if> 8158 </td> 8159 </tr> 8160 </xsl:for-each> 8161 </tbody> 8162 </table> 8021 <div id="bwCurrentAccessWidget"> </div> 8022 <script type="text/javascript"> 8023 bwAcl.display("bwCurrentAccessWidget"); // display acls in the table 8024 </script> 8163 8025 </xsl:template> 8164 8026 … … 8402 8264 </xsl:template> 8403 8265 8404 <!-- return string values to be loaded into javascript for access control 8405 forms, method 2 --> 8266 <!-- return string values to be loaded into javascript for access control forms --> 8406 8267 <xsl:template match="ace" mode="initJS"><!-- 8407 8268 --><xsl:variable name="who"><!-- trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkAccess.js
r2076 r2077 55 55 var allStr = "all"; 56 56 57 var deleteStr = "remove"; 57 var bwAclWidgetDeleteStr = "remove"; 58 var bwAclWidgetEntryStr = "Entry"; 59 var bwAclWidgetAccessStr = "Access"; 60 var bwAclWidgetInheritedStr = "Inherited from"; 58 61 59 62 // note that resourcesRoot is passed in from the html head section defined in the xslt … … 258 261 } 259 262 260 // Gather up the how values on access form submission and set the how field 261 // (method 1) or return the value (method 2). 263 // Gather up the how values on access form submission and return the value. 262 264 // If in "basic" mode: 263 265 // Set the value of how to the value of the basicHowItem radio button. … … 267 269 // The allow/deny flag contains the final values to be returned with 268 270 // the "-" switch if we set the value to deny (e.g. "A" or "-A", "R" or "-R"). 269 // Method: there are two methods used with this function; method one sets 270 // the "how" field in the form used to update a single principal. Method 271 // two returns the assembled how string to the calling function. 272 function setAccessHow(formObj,method) { 271 function setAccessHow(formObj) { 273 272 var howString = ""; 274 273 if (formObj.setappvar[0].checked == true) { // "basic" mode is selected … … 290 289 } 291 290 } 292 if (method == 2) { 293 return howString; 294 } else { 295 formObj.how.value = howString; 296 } 291 return howString; 297 292 } 298 293 … … 435 430 436 431 this.equals = function(pr) { 437 //alert("this=" + this.toString() + " pr=" + pr.toString());438 439 432 if (this.whoType != pr.whoType) { 440 433 return false; 441 434 } 442 443 435 return this.who == pr.who; 444 436 } 445 437 } 446 438 447 /* METHOD TWO FUNCTIONS*/ 448 // Access Control Entry (ACE) object 449 439 /* Access Control Entry (ACE) object 440 */ 450 441 function bwAce(who, whoType, how, inherited, invert) { 451 442 this.principal = new bwPrincipal(who, whoType); … … 555 546 // row: current row in table 556 547 // aceI: index of the ace 557 this.toFormRow = function(row, aceI) { 548 // id: id of widget output block in the html 549 this.toFormRow = function(row, aceI, id) { 558 550 var td_0 = row.insertCell(0); 559 551 td_0.innerHTML = this.principal.format(); … … 563 555 var td_3 = row.insertCell(3); 564 556 if (this.inherited == "") { 565 td_3.innerHTML = "<a href=\"javascript:bwAcl.deleteAce('" + aceI + "' )\">" + trashIcon + " " + deleteStr + "</a>";557 td_3.innerHTML = "<a href=\"javascript:bwAcl.deleteAce('" + aceI + "','" + id + "')\">" + trashIcon + " " + bwAclWidgetDeleteStr + "</a>"; 566 558 } 567 559 } … … 603 595 604 596 // Update the list - expects the browser form object 605 this.update = function(formObj ) {597 this.update = function(formObj,id) { 606 598 // get the type of ace being set 607 599 var type; … … 620 612 621 613 // get the how string from the form 622 var how = setAccessHow(formObj , 2);614 var how = setAccessHow(formObj); 623 615 624 616 //alert("About to update who=" + formObj.who.value + … … 633 625 634 626 // redraw the display 635 this.display( );636 } 637 638 this.deleteAce = function(index ) {627 this.display(id); 628 } 629 630 this.deleteAce = function(index,id) { 639 631 var ace = aces[index]; 640 632 var replace = false; … … 659 651 660 652 // redraw the display 661 this.display( );662 } 663 664 // update the ACL table displayed on screen665 this.display = function( ) {653 this.display(id); 654 } 655 656 // build the ACL widget displayed on screen in the given id 657 this.display = function(id) { 666 658 try { 659 660 var aclWidget = document.getElementById(id); 661 aclWidget.innerHTML = ""; 662 663 var bwCurrentAccess = document.createElement("table"); 664 bwCurrentAccess.className = "common scheduling"; 665 bwCurrentAccess.id = "bwCurrentAccess"; 666 bwCurrentAccess.createTHead(); 667 bwCurrAccessHead = bwCurrentAccess.tHead.insertRow(0); 668 bwCurrAccessHead.innerHTML = '<th>' + bwAclWidgetEntryStr + '</th>' + '<th>' + bwAclWidgetAccessStr + '</th>' + '<th>' + bwAclWidgetInheritedStr + '</th><th></th>'; 669 var bwCurrAccessTBody = document.createElement("tbody"); 670 bwCurrentAccess.appendChild(bwCurrAccessTBody); 671 672 // finally, write the table back to the display 673 aclWidget.appendChild(bwCurrentAccess); 674 667 675 // get the table body 668 676 var aclTableBody = document.getElementById("bwCurrentAccess").tBodies[0]; 669 677 670 678 // remove existing rows 671 for (i = aclTableBody.rows.length - 1; i >= 0; i--) {672 aclTableBody.deleteRow(i);673 }674 675 // recreate the table rows679 //for (i = aclTableBody.rows.length - 1; i >= 0; i--) { 680 // aclTableBody.deleteRow(i); 681 //} 682 683 // create the table rows 676 684 for (var j = 0; j < aces.length; j++) { 677 685 var curAce = aces[j]; 678 686 var tr = aclTableBody.insertRow(j); 679 687 680 curAce.toFormRow(tr, j); 681 } 688 curAce.toFormRow(tr, j, id); 689 } 690 682 691 } catch (e) { 683 692 alert(e); trunk/deployment/webuser/webapp/resources/demoskins/resources/bedeworkEventForm.js
r2061 r2077 243 243 } // else we are editing an instance of a recurrence 244 244 setBedeworkXProperties(formObj,submitter); 245 setAccessHow(formObj ,1);245 setAccessHow(formObj); 246 246 //setAccessAcl(formObj); 247 247 }
