Changeset 2991

Show
Ignore:
Timestamp:
08/28/10 01:20:31
Author:
johnsa
Message:

web clients: disallow troublesome characters in calendar system names
user client: use better date picker

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/deployment/webadmin/webapp/resources/default/default/strings.xsl

    r2863 r2991  
    453453  <xsl:variable name="bwStr-CuCa-AddCalFileOrSub">Add Calendar, Folder, or Subscription</xsl:variable> 
    454454  <xsl:variable name="bwStr-CuCa-NoteAccessSet">Note: Access may be set on a calendar after it is created.</xsl:variable> 
    455   <xsl:variable name="bwStr-CuCa-Name">Name:</xsl:variable> 
    456   <xsl:variable name="bwStr-CuCa-Summary">Summary:</xsl:variable> 
     455  <xsl:variable name="bwStr-CuCa-Name">System Name:</xsl:variable> 
     456  <xsl:variable name="bwStr-CuCa-Summary">Display Name:</xsl:variable> 
    457457  <xsl:variable name="bwStr-CuCa-Description">Description:</xsl:variable> 
    458458  <xsl:variable name="bwStr-CuCa-Filter">Filter:</xsl:variable> 
     
    502502  <xsl:variable name="bwStr-CaLD-CalendarInfo">Calendar Information</xsl:variable> 
    503503  <xsl:variable name="bwStr-CaLD-SelectItemFromCalendarTree">Select an item from the calendar tree on the left to view all information about that calendar or folder.  The tree on the left represents the calendar heirarchy.</xsl:variable> 
    504   <xsl:variable name="bwStr-CaLD-Name">Name:</xsl:variable> 
     504  <xsl:variable name="bwStr-CaLD-Name">System Name:</xsl:variable> 
    505505  <xsl:variable name="bwStr-CaLD-Path">Path:</xsl:variable> 
    506   <xsl:variable name="bwStr-CaLD-Summary">Summary:</xsl:variable> 
     506  <xsl:variable name="bwStr-CaLD-Summary">Display Name:</xsl:variable> 
    507507  <xsl:variable name="bwStr-CaLD-Description">Description:</xsl:variable> 
    508508 
     
    530530  <xsl:variable name="bwStr-CaMv-MoveCalendar">Move Calendar/Folder</xsl:variable> 
    531531  <xsl:variable name="bwStr-CaMv-CurrentPath">Current Path:</xsl:variable> 
    532   <xsl:variable name="bwStr-CaMv-Name">Name:</xsl:variable> 
     532  <xsl:variable name="bwStr-CaMv-Name">System Name:</xsl:variable> 
    533533  <xsl:variable name="bwStr-CaMv-MailingListID">Mailing List ID:</xsl:variable> 
    534   <xsl:variable name="bwStr-CaMv-Summary">Summary:</xsl:variable> 
     534  <xsl:variable name="bwStr-CaMv-Summary">Display Name:</xsl:variable> 
    535535  <xsl:variable name="bwStr-CaMv-Description">Description:</xsl:variable> 
    536536  <xsl:variable name="bwStr-CaMv-SelectNewParentFolder">Select a new parent folder:</xsl:variable> 
     
    895895  <xsl:variable name="bwStr-Srch-ResultReturnedFor">result(s) returned for</xsl:variable> 
    896896  <xsl:variable name="bwStr-Srch-Relevance">relevance</xsl:variable> 
    897   <xsl:variable name="bwStr-Srch-Summary">summary</xsl:variable> 
     897  <xsl:variable name="bwStr-Srch-Summary">display name</xsl:variable> 
    898898  <xsl:variable name="bwStr-Srch-Title">title</xsl:variable> 
    899899  <xsl:variable name="bwStr-Srch-DateAndTime">date &amp; time</xsl:variable> 
  • trunk/deployment/webadmin/webapp/resources/resources/bedework.js

    r2850 r2991  
    181181    return false; 
    182182  } 
    183  
    184   // set the aliasUri to an empty string.  Only set it if user 
    185   // has requested a subscription. 
    186   formObj.aliasUri.value == ""; 
    187  
    188   if (formObj.type.value == "folder") { 
    189     formObj.calendarCollection.value = "false"; 
    190   } else if (formObj.type.value == "subscription") { 
    191     switch (formObj.subType.value) { 
    192       case "publicTree": 
    193         // do nothing: when adding a subscription to the public tree, we set the fields directly. 
    194         break; 
    195       case "public": 
    196         formObj.aliasUri.value = "bwcal://" + formObj.publicAliasHolder.value; 
    197         break; 
    198       case "user": 
    199         //the "/user/" string is temporary; it needs to be passed as a param. 
    200         formObj.aliasUri.value = "bwcal:///user/" + formObj.userIdHolder.value + "/" + formObj.userCalHolder.value; 
    201         break; 
    202       case "external": 
    203         formObj.aliasUri.value = formObj.aliasUriHolder.value; 
    204         break; 
    205     } 
    206   } 
    207   return true; 
    208 
    209 // build a uri based on user and path in the subscription form 
    210 // DEPRECATED - use setCalendarAlias() above. 
    211 function setSubscriptionUri(formObj,prefix) { 
    212   if (formObj) { 
    213     var fullUri =  prefix + formObj.userId.value; 
    214     if (formObj.userPath.value != "") { 
    215       if (formObj.userPath.value.substring(0,1) == "/") { 
    216         fullUri += formObj.userPath.value; 
    217       } else { 
    218         fullUri += "/" + formObj.userPath.value; 
     183   
     184  // check first to make sure we have a valid calendar system name: 
     185  if (validateCalName(formObj['calendar.name'])) { 
     186     
     187    // set the aliasUri to an empty string.  Only set it if user 
     188    // has requested a subscription. 
     189    formObj.aliasUri.value == ""; 
     190   
     191    if (formObj.type.value == "folder") { 
     192      formObj.calendarCollection.value = "false"; 
     193    } else if (formObj.type.value == "subscription") { 
     194      switch (formObj.subType.value) { 
     195        case "publicTree": 
     196          // do nothing: when adding a subscription to the public tree, we set the fields directly. 
     197          break; 
     198        case "public": 
     199          formObj.aliasUri.value = "bwcal://" + formObj.publicAliasHolder.value; 
     200          break; 
     201        case "user": 
     202          //the "/user/" string is temporary; it needs to be passed as a param. 
     203          formObj.aliasUri.value = "bwcal:///user/" + formObj.userIdHolder.value + "/" + formObj.userCalHolder.value; 
     204          break; 
     205        case "external": 
     206          formObj.aliasUri.value = formObj.aliasUriHolder.value; 
     207          break; 
    219208      } 
    220209    } 
    221     formObj.calUri.value = fullUri; 
    222210    return true; 
    223211  } else { 
    224     alert("The subscription form is not available."); 
    225212    return false; 
    226213  } 
     
    262249    hiddenCat.innerHTML = '<input type="hidden" name="defaultCategory" value=""/>'; 
    263250    formObj.appendChild(hiddenCat); 
     251  } 
     252} 
     253// Stop user from entering invalid characters in calendar names 
     254// In 3.6 this will only test for & ' " and / 
     255// In future releases, we will go further and only allow  
     256// alphanumerics and dashes and underscores. 
     257function validateCalName(nameObj) { 
     258  if(nameObj.value.indexOf("'") == -1 &&  
     259     nameObj.value.indexOf('"') == -1 && 
     260     nameObj.value.indexOf("&") == -1 &&  
     261     nameObj.value.indexOf("/") == -1) { 
     262    return true; 
     263  } else { // we have bad characters 
     264    var badChars = ""; 
     265    if(nameObj.value.indexOf("'") != -1) { 
     266      badChars += " ' ";  
     267    } 
     268    if(nameObj.value.indexOf('"') != -1) { 
     269      badChars += ' \" ';  
     270    } 
     271    if(nameObj.value.indexOf("&") != -1) { 
     272      badChars += " & ";  
     273    } 
     274    if(nameObj.value.indexOf("/") != -1) { 
     275      badChars += " / ";  
     276    } 
     277    alert("System Names may not include the following characters: " + badChars); 
     278    nameObj.focus(); 
     279    return false;  
    264280  } 
    265281} 
  • trunk/deployment/webuser/webapp/resources/demoskins/default/strings.xsl

    r2913 r2991  
    578578  <xsl:variable name="bwStr-CuCa-AddCalFolderOrSubscription">Add Calendar, Folder, or Subscription</xsl:variable> 
    579579  <xsl:variable name="bwStr-CuCa-HttpStatus">HTTP Status:</xsl:variable> 
    580   <xsl:variable name="bwStr-CuCa-Name">Name:</xsl:variable> 
    581   <xsl:variable name="bwStr-CuCa-Summary">Summary:</xsl:variable> 
     580  <xsl:variable name="bwStr-CuCa-Name">System Name:</xsl:variable> 
     581  <xsl:variable name="bwStr-CuCa-Summary">Display Name:</xsl:variable> 
    582582  <xsl:variable name="bwStr-CuCa-Description">Description:</xsl:variable> 
    583583  <xsl:variable name="bwStr-CuCa-Color">Color:</xsl:variable> 
     
    10571057  <xsl:variable name="bwStr-Srch-ResultReturnedFor">result(s) returned for</xsl:variable> 
    10581058  <xsl:variable name="bwStr-Srch-Relevance">relevance</xsl:variable> 
    1059   <xsl:variable name="bwStr-Srch-Summary">summary</xsl:variable> 
     1059  <xsl:variable name="bwStr-Srch-Summary">display name</xsl:variable> 
    10601060  <xsl:variable name="bwStr-Srch-DateAndTime">date &amp; time</xsl:variable> 
    10611061  <xsl:variable name="bwStr-Srch-Calendar">calendar</xsl:variable> 
  • trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/calendars.xsl

    r2896 r2991  
    119119          <xsl:choose> 
    120120            <xsl:when test="display = 'true'"> 
    121               <!-- set the value of display to false so that when the form is submitted we toggle --> 
     121              <!-- set the value of display to false so that when the form is submitted we toggle 
     122--> 
    122123              <input type="hidden" name="display" value="false"/> 
    123124              <input type="checkbox" name="bwDisplaySetter" checked="checked"  onclick="this.form.submit()"> 
     
    128129            </xsl:when> 
    129130            <xsl:otherwise> 
    130               <!-- set the value of display to true so that when the form is submitted we toggle --> 
     131              <!-- set the value of display to true so that when the form is submitted we toggle 
     132--> 
    131133              <input type="hidden" name="display" value="true"/> 
    132134              <input type="checkbox" name="bwDisplaySetter" onclick="this.form.submit()"> 
     
    367369 
    368370  <xsl:template name="selectCalForPublicAlias"> 
    369   <!-- This template is DEPRECATED ... selectCalForPublicAliasCalTree is now used instead. --> 
     371  <!-- This template is DEPRECATED ... selectCalForPublicAliasCalTree is now used instead. 
     372--> 
    370373  <!-- selectCalForPublicAlias creates a calendar tree pop-up window for 
    371        selecting a public calendar subscription (alias). --> 
     374       selecting a public calendar subscription (alias). 
     375--> 
    372376 
    373377    <input type="button" onclick="javascript:changeClass('calSelectWidget','visible')" value="select calendar" class="small"/> 
     
    429433  <xsl:template match="currentCalendar" mode="addCalendar"> 
    430434    <h3><xsl:copy-of select="$bwStr-CuCa-AddCalFolderOrSubscription"/></h3> 
    431     <form name="addCalForm" method="post" action="{$calendar-update}" onsubmit="setCalendarAlias(this)"> 
     435    <form name="addCalForm" method="post" action="{$calendar-update}" onsubmit="return setCalendarAlias(this)"> 
    432436      <table class="common"> 
    433437        <tr> 
     
    690694              <xsl:call-template name="colorPicker"> 
    691695                <xsl:with-param name="colorFieldId">bwCalColor</xsl:with-param> 
     696                <xsl:with-param name="colorValue"><xsl:value-of select="color"/></xsl:with-param> 
    692697              </xsl:call-template> 
    693698            </td> 
     
    831836  <xsl:template name="colorPicker"> 
    832837    <xsl:param name="colorFieldId"/><!-- required: id of text field to be updated --> 
     838    <button type="button" id="bwColorPickerButton" value="{$bwStr-CoPi-Pick}"><img src="{$resourcesRoot}/images/colorIcon.gif" width="16" height="13" alt="pick a color"/></button> 
    833839    <script type="text/javascript"> 
    834       $.ui.dialog.defaults.bgiframe = true; 
    835       $(function() { 
    836         $("#bwColorPicker").dialog({ autoOpen: false, width: 214 }); 
    837       }); 
    838       $(function() { 
    839         $('#bwColorPickerButton').click(function() { 
    840           $('#bwColorPicker').dialog('open'); 
    841         }); 
     840      $(document).ready(function() { 
     841        $('#bwColorPickerButton').ColorPicker({ 
     842                                  onSubmit: function(hsb, hex, rgb, el) { 
     843              var fullHex = "#" + hex; 
     844              $('#<xsl:value-of select="$colorFieldId"/>').val(fullHex); 
     845              $('#<xsl:value-of select="$colorFieldId"/>').css('background-color',fullHex); 
     846              $(el).ColorPickerHide(); 
     847            }, 
     848            onBeforeShow: function () { 
     849              var curColor = $('#<xsl:value-of select="$colorFieldId"/>').val(); 
     850              $(this).ColorPickerSetColor(curColor); 
     851            } 
     852                                }); 
    842853      }); 
    843854    </script> 
    844     <button type="button" id="bwColorPickerButton" value="{$bwStr-CoPi-Pick}"><img src="{$resourcesRoot}/images/colorIcon.gif" width="16" height="13" alt="pick a color"/></button> 
    845  
    846     <div id="bwColorPicker" title="{$bwStr-CoPi-SelectColor}"> 
    847       <xsl:for-each select="document('../../../bedework-common/default/default/subColors.xml')/subscriptionColors/color"> 
    848         <xsl:variable name="color" select="."/> 
    849         <xsl:variable name="colorName" select="@name"/> 
    850         <a href="javascript:bwUpdateColor('{$color}','{$colorFieldId}')" 
    851            style="display:block;float:left;background-color:{$color};color:black;width=25px;height=25px;margin:0;padding:0;" 
    852            title="{$colorName}" 
    853            onclick="$('#bwColorPicker').dialog('close');"> 
    854           <img src="{$resourcesRoot}/images/spacer.gif" width="25" height="25" style="border:1px solid #333;margin:0;padding:0;" alt="{$colorName}"/> 
    855         </a> 
    856         <xsl:if test="position() mod 6 = 0"><br style="clear:both;"/></xsl:if> 
    857       </xsl:for-each> 
    858       <p><a href="javascript:bwUpdateColor('','{$colorFieldId}')" onclick="$('#bwColorPicker').dialog('close');"><xsl:copy-of select="$bwStr-CoPi-UseDefaultColors"/></a></p> 
    859     </div> 
    860855  </xsl:template> 
    861856 
  • trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/head.xsl

    r2986 r2991  
    7777      </xsl:if> 
    7878    </xsl:if> 
     79     
     80    <xsl:if test="/bedework/page='modCalendar' or 
     81                  /bedework/page='addCalendar'"> 
     82      <link rel="stylesheet" href="/bedework-common/javascript/jquery/colorpicker/colorpicker.css"/> 
     83      <script type="text/javascript" src="/bedework-common/javascript/jquery/colorpicker/colorpicker.js">&#160;</script>         
     84    </xsl:if> 
    7985 
    8086    <xsl:if test="/bedework/page='attendees'"> 
  • trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/javascript/bedework.js

    r2893 r2991  
    206206  } 
    207207 
    208   // set the aliasUri to an empty string.  Only set it if user 
    209   // has requested a subscription. 
    210   formObj.aliasUri.value == ""; 
    211  
    212   if (formObj.type.value == "folder") { 
    213     formObj.calendarCollection.value = "false"; 
    214   } else if (formObj.type.value == "subscription") { 
    215     switch (formObj.subType.value) { 
    216       case "public": 
    217         formObj.aliasUri.value = "bwcal://" + formObj.publicAliasHolder.value; 
    218         break; 
    219       case "user": 
    220         //the "/user/" string is temporary; it needs to be passed as a param. 
    221         formObj.aliasUri.value = "bwcal:///user/" + formObj.userIdHolder.value + "/" + formObj.userCalHolder.value; 
    222         break; 
    223       case "external": 
    224         formObj.aliasUri.value = formObj.aliasUriHolder.value; 
    225         break; 
    226     } 
    227   } 
    228   return true; 
    229 
    230 // build a uri based on user and path in the subscription form 
    231 // DEPRECATED - use setCalendarAlias() above. 
    232 function setBwSubscriptionUri(formObj, publicUri) { 
    233   if (!formObj) { 
    234     alert("The subscription form is not available."); 
     208  //check first to make sure we have a valid calendar system name: 
     209  if (validateCalName(formObj['calendar.name'])) { 
     210   
     211    // set the aliasUri to an empty string.  Only set it if user 
     212    // has requested a subscription. 
     213    formObj.aliasUri.value == ""; 
     214   
     215    if (formObj.type.value == "folder") { 
     216      formObj.calendarCollection.value = "false"; 
     217    } else if (formObj.type.value == "subscription") { 
     218      switch (formObj.subType.value) { 
     219        case "public": 
     220          formObj.aliasUri.value = "bwcal://" + formObj.publicAliasHolder.value; 
     221          break; 
     222        case "user": 
     223          //the "/user/" string is temporary; it needs to be passed as a param. 
     224          formObj.aliasUri.value = "bwcal:///user/" + formObj.userIdHolder.value + "/" + formObj.userCalHolder.value; 
     225          break; 
     226        case "external": 
     227          formObj.aliasUri.value = formObj.aliasUriHolder.value; 
     228          break; 
     229      } 
     230    } 
     231    return true; 
     232  } else { 
    235233    return false; 
    236234  } 
    237  
    238   var fullUri = "bwcal://"; 
    239  
    240   if (publicUri) { 
    241     fullUri += formObj.aliasUri.value; 
    242   } else { 
    243     fullUri +=  "/user" + formObj.userId.value; 
    244     if (formObj.userPath.value != "") { 
    245       if (formObj.userPath.value.substring(0,1) != "/") { 
    246         fullUri += "/"; 
    247       } 
    248  
    249       fullUri += formObj.userPath.value; 
    250     } 
    251   } 
    252  
    253   formObj.aliasUri.value = fullUri; 
    254   return true; 
     235
     236//Stop user from entering invalid characters in calendar names 
     237//In 3.6 this will only test for & ' " and / 
     238//In future releases, we will go further and only allow  
     239//alphanumerics and dashes and underscores. 
     240function validateCalName(nameObj) { 
     241  if(nameObj.value.indexOf("'") == -1 &&  
     242    nameObj.value.indexOf('"') == -1 && 
     243    nameObj.value.indexOf("&") == -1 &&  
     244    nameObj.value.indexOf("/") == -1) { 
     245   return true; 
     246  } else { // we have bad characters 
     247   var badChars = ""; 
     248   if(nameObj.value.indexOf("'") != -1) { 
     249     badChars += " ' ";  
     250   } 
     251   if(nameObj.value.indexOf('"') != -1) { 
     252     badChars += ' \" ';  
     253   } 
     254   if(nameObj.value.indexOf("&") != -1) { 
     255     badChars += " & ";  
     256   } 
     257   if(nameObj.value.indexOf("/") != -1) { 
     258     badChars += " / ";  
     259   } 
     260   alert("System Names may not include the following characters: " + badChars); 
     261   nameObj.focus(); 
     262   return false;  
     263  } 
    255264} 
    256265function exportCalendar(formId,name,calPath) {