 +				<label for="shoppingVisibilityStart">$tlang.getString("shopping.start.label"): </label>
 +				</td>
 +				<td>
-+				<input type="text" id="shoppingVisibilityStart" name="shoppingVisibilityStart" class="shoppingSetting" value="$shopping_visibility_start"/>
++				<input type="text" id="shoppingVisibilityStart" name="shoppingVisibilityStart" class="shoppingSetting" value=""/>
 +				</td>
 +				</tr>
 +                                <tr>

Index: site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java
===================================================================
--- site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java	(revision 104522)
+++ site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java	(working copy)
@@ -21,11 +21,15 @@
 
 import java.io.IOException;
 import java.lang.reflect.Method;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -181,6 +185,9 @@
 	private static org.sakaiproject.sitemanage.api.model.SiteSetupQuestionService questionService = (org.sakaiproject.sitemanage.api.model.SiteSetupQuestionService) ComponentManager
 	.get(org.sakaiproject.sitemanage.api.model.SiteSetupQuestionService.class);
 	
+	private static org.sakaiproject.email.api.EmailService emailService = (org.sakaiproject.email.api.EmailService) ComponentManager
+	.get(org.sakaiproject.email.api.EmailService.class);
+	
 	private static final String SITE_MODE_SITESETUP = "sitesetup";
 
 	private static final String SITE_MODE_SITEINFO = "siteinfo";
@@ -430,7 +437,18 @@
 	private static final String STATE_SITE_ACCESS_PUBLISH = "state_site_access_publish";
 	
 	private static final String STATE_SITE_ACCESS_INCLUDE = "state_site_access_include";
+	
+	/** Shopping Period state */
+	private static final String STATE_SITE_ACCESS_SHOPPING_VISIBILITY = "state_site_access_visibility";
 
+	private static final String STATE_SITE_ACCESS_SHOPPING_VISIBILITY_START = "state_site_access_shopping_start";
+
+	private static final String STATE_SITE_ACCESS_SHOPPING_VISIBILITY_END = "state_site_access_shopping_end";
+	
+	private static final String STATE_SITE_ACCESS_SHOPPING_ROLE = "state_site_access_shopping_role";
+	
+	private static final String STATE_SITE_ACCESS_SHOPPING_REALM = "state_site_access_shopping_realm";
+
 	/** the list of selected user */
 	private static final String STATE_SELECTED_USER_LIST = "state_selected_user_list";
 
@@ -967,10 +985,8 @@
 				}
 	
 				state.setAttribute(STATE_SITE_MODE, site_mode);
-			}
+		}
 
-
-		
 	} // initState
 	
 	
@@ -2298,6 +2314,19 @@
 				}
 				context.put("published", state.getAttribute(STATE_SITE_ACCESS_PUBLISH));
 				context.put("include", state.getAttribute(STATE_SITE_ACCESS_INCLUDE));
+				context.put("shopping_visibility", state.getAttribute(STATE_SITE_ACCESS_SHOPPING_VISIBILITY));
+				String start = (String) state.getAttribute(STATE_SITE_ACCESS_SHOPPING_VISIBILITY_START);
+				if (start == null) {
+					start = "";
+				}
+				String end = (String) state.getAttribute(STATE_SITE_ACCESS_SHOPPING_VISIBILITY_END);
+				if (end == null) {
+					end = "";
+				}
+				context.put("shopping_visibility_start", start);
+				context.put("shopping_visibility_end", end);
+				context.put("all_roles", site.getRoles());
+				context.put("shoppingPeriodInstructorEditable", ServerConfigurationService.getBoolean("delegatedaccess.shopping.instructorEditable", false));
 
 				if (siteType != null && !unJoinableSiteTypes.contains(siteType)) {
 					// site can be set as joinable
@@ -6571,7 +6600,7 @@
 					}
 				}
 			}
-			state.setAttribute(STATE_JOINERROLE, joinerRole); 
+			state.setAttribute(STATE_JOINERROLE, joinerRole);
 		}
 		catch (Exception e)
 		{
@@ -7213,6 +7242,9 @@
 		readInputAndUpdateStateVariable(state, params, "include", STATE_SITE_ACCESS_INCLUDE, true);
 		readInputAndUpdateStateVariable(state, params, "joinable", STATE_JOINABLE, true);
 		readInputAndUpdateStateVariable(state, params, "joinerRole", STATE_JOINERROLE, false);
+		readInputAndUpdateStateVariable(state, params, "shoppingVisibility",      STATE_SITE_ACCESS_SHOPPING_VISIBILITY, false);
+		readInputAndUpdateStateVariable(state, params, "shoppingVisibilityStart", STATE_SITE_ACCESS_SHOPPING_VISIBILITY_START, false);
+		readInputAndUpdateStateVariable(state, params, "shoppingVisibilityEnd",   STATE_SITE_ACCESS_SHOPPING_VISIBILITY_END, false);
 		
 		boolean publishUnpublish = state.getAttribute(STATE_SITE_ACCESS_PUBLISH) != null ? ((Boolean) state.getAttribute(STATE_SITE_ACCESS_PUBLISH)).booleanValue() : false;
 		
Index: site-manage-tool/tool/src/bundle/sitesetupgeneric.properties
===================================================================
--- site-manage-tool/tool/src/bundle/sitesetupgeneric.properties	(revision 104522)
+++ site-manage-tool/tool/src/bundle/sitesetupgeneric.properties	(working copy)
@@ -1057,3 +1057,20 @@
 sitegen.siteinfolist.usermodify = Modified by

 				<input type="submit" accesskey="x"  name="eventSubmit_doCancel" value="$tlang.getString("ediacc.bac")" />
 #else
 				<input type="submit" accesskey="s" class="active" name="eventSubmit_doUpdate_site_access" value="$tlang.getString("ediacc.con")" />
Index: site-manage-tool/tool/src/webapp/js/site-manage-shopping.js
===================================================================
--- site-manage-tool/tool/src/webapp/js/site-manage-shopping.js	(revision 0)
+++ site-manage-tool/tool/src/webapp/js/site-manage-shopping.js	(revision 0)
@@ -0,0 +1,152 @@
+// Shopping Period JS
+$(document).ready(function(){
+
+	// Decorate the date inputs
+	$("#shoppingVisibilityStart").datepicker();
+	$("#shoppingVisibilityEnd").datepicker();
+	
+	// Get the shopping info for this site from a WS
+	$.getJSON("/direct/delegated_access/" + $('#siteId').html() + ".json",
+		function(response){
+			var data = response.data;
+		
+			//add auth options
+			$.getJSON("/direct/delegated_access/shoppingOptions/authorization.json", 
+				function(response){
+					for (var i=0; i<response.delegated_access_collection.length; i++) {
+						if(response.delegated_access_collection[i].key === data.shoppingAuth){
+							$('#shoppingVisibility')
+								.append($("<option selected></option>")
+								.attr("value",response.delegated_access_collection[i].key)
+								.text(response.delegated_access_collection[i].value));
+						}else{
+							$('#shoppingVisibility')
+								.append($("<option></option>")
+								.attr("value",response.delegated_access_collection[i].key)
+								.text(response.delegated_access_collection[i].value));
+						}
+					}
+				}
+			);
+			
+			//add role options
+			$.getJSON("/direct/delegated_access/shoppingOptions/roles.json", 
+				function(response){
+					for (var i=0; i<response.delegated_access_collection.length; i++) {
+						if(response.delegated_access_collection[i].key === data.shoppingRealm + ":" + data.shoppingRole){
+							$('#shoppingRole')
+								.append($("<option selected></option>")
+								.attr("value",response.delegated_access_collection[i].key)
+								.text(response.delegated_access_collection[i].value));
+						}else{
+							$('#shoppingRole')
+								.append($("<option></option>")
+								.attr("value",response.delegated_access_collection[i].key)
+								.text(response.delegated_access_collection[i].value));
+						}
+					}
+				}
+			);
+			//add showTools options
+			$.getJSON("/direct/delegated_access/shoppingOptions/tools.json", 
+				function(response){
+					for (var i=0; i<response.delegated_access_collection.length; i++) {
+						if($.inArray(response.delegated_access_collection[i].key, data.shoppingShowTools) >= 0){
+							$('#showTools')
+								.append($("<option selected></option>")
+								.attr("value",response.delegated_access_collection[i].key)
+								.text(response.delegated_access_collection[i].value));
+						}else{
+							$('#showTools')
+								.append($("<option></option>")
+								.attr("value",response.delegated_access_collection[i].key)
+								.text(response.delegated_access_collection[i].value));
+						}
+					}
+				}
+			);
+		
+            
+            $('#shoppingVisibilityDiv').show();
+            $('#shoppingVisibility').val(data.shoppingAuth);
+            
+            if (data.shoppingStartDate != undefined && data.shoppingStartDate != ""){
+                var shoppingStartDate = new Date(parseInt(data.shoppingStartDate));
+                $('#shoppingVisibilityStart').val($.datepicker.formatDate("mm/dd/yy", shoppingStartDate));
+            }
+            if (data.shoppingEndDate != undefined && data.shoppingEndDate != ""){
+                var shoppingEndDate = new Date(parseInt(data.shoppingEndDate));
+                $('#shoppingVisibilityEnd').val($.datepicker.formatDate("mm/dd/yy", shoppingEndDate));
+            }
+            
+            //disable options if this shopping site isn't directAccess (option for overriding inheritted settings)
+            if(!data.directAccess){
+            	setShoppingSettingsDisabled(true);
+            }else{
+            	$('#shoppingPeriodOverride').attr("checked", true);
+            }
+	    }
+	);
+	
+	
+	
+	// Gather the shopping variables and save them to a WS
+	$("#updateButton").click(function(){
+        try {
+	     
+            var start = "";
+		    try{
+			start  = $.datepicker.parseDate("mm/dd/yy", $('#shoppingVisibilityStart').val()).getTime();
+		    }catch(err){}
+		    var end = "";
+		    try{
+			end   = $.datepicker.parseDate("mm/dd/yy", $('#shoppingVisibilityEnd').val()).getTime();
+		    }catch(err){}
+		    var shoppingRole = "";
+		    var shoppingRealm = "";
+		    try{
+		    	var split = $("#shoppingRole").val().split(":");
+		    	shoppingRealm = split[0];
+		    	shoppingRole = split[1];
+		    }catch(err){
+		    	shoppingRealm = "";
+		    	shoppingRole = "";
+		    }
+            var data = {
+                'shoppingAuth'      : $('#shoppingVisibility option:selected').val(),
+                'shoppingStartDate' : start,
+                'shoppingEndDate'   : end,
+                'shoppingRealm'     : shoppingRealm,
+                'shoppingRole'      : shoppingRole,
+                'shoppingShowTools' : $('#showTools').val(),
+                'directAccess': document.getElementById('shoppingPeriodOverride').checked
+            };
+            var form = $('form[name=editParticipantForm]');
+
+            $.ajax({
+                type: 'POST',
+                url: "/direct/delegated_access/" + $('#siteId').html() + ".json",
+                data: data,
+                async:false,
+                failure: function failure(data){
+                    // TODO: internationalize
+                    alert("There was an error saving the shopping period info.");
+                    },
+                });
+        }
+        catch (error){
+            console.log(error);
+        }
+	});
+});
+
+function setShoppingSettingsDisabled(disabled){
+	$(".shoppingSetting").attr("disabled", disabled);
+}
+
+function optOutOfShoppingPeriod(){
+	$('#shoppingPeriodOverride').attr('checked', true);
+	$('.shoppingSetting').attr('value', '');
+	setShoppingSettingsDisabled(false)
+}
+

Property changes on: site-manage-tool/tool/src/webapp/js/site-manage-shopping.js
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author HeadURL Id
Added: svn:eol-style
   + native

