@@ -2864,7 +2864,8 @@ public int compare(JoinableGroup g1, JoinableGroup g2){
2864
2864
case 26:
2865
2865
/*
2866
2866
* buildContextForTemplate chef_site-modifyENW.vm
2867
- *
2867
+ * When editing the list of tools this is called to set options that some tools require.
2868
+ * For example the mail archive tools needs an alias before it can start to be used.
2868
2869
*/
2869
2870
site_type = (String) state.getAttribute(STATE_SITE_TYPE);
2870
2871
boolean existingSite = site != null ? true : false;
@@ -3945,39 +3946,37 @@ private void buildLTIToolContextForTemplate(Context context,
3945
3946
List<Map<String, Object>> visibleTools, allTools;
3946
3947
// get the visible and all (including stealthed) list of lti tools
3947
3948
visibleTools = m_ltiService.getTools(null,null,0,0);
3948
- if (site == null)
3949
+ if (site == null) {
3949
3950
allTools = visibleTools;
3950
- else
3951
- allTools = m_ltiService.getToolsDao(null,null,0,0,site.getId());
3952
-
3953
- if (visibleTools != null && !visibleTools.isEmpty())
3954
- {
3955
- HashMap<String, Map<String, Object>> ltiTools = new HashMap<String, Map<String, Object>>();
3956
- // get invoke count for all lti tools
3957
- List<Map<String,Object>> contents = m_ltiService.getContents(null,null,0,0);
3958
- HashMap<String, Map<String, Object>> linkedLtiContents = new HashMap<String, Map<String, Object>>();
3959
- for ( Map<String,Object> content : contents ) {
3960
- String ltiToolId = content.get(m_ltiService.LTI_TOOL_ID).toString();
3961
- String siteId = StringUtils.trimToNull((String) content.get(m_ltiService.LTI_SITE_ID));
3962
- if (siteId != null)
3963
- {
3964
- // whether the tool is already enabled in site
3965
- String pstr = (String) content.get(LTIService.LTI_PLACEMENT);
3966
- if (StringUtils.trimToNull(pstr) != null && site != null)
3967
- {
3968
- // the lti tool is enabled in the site
3969
- ToolConfiguration toolConfig = SiteService.findTool(pstr);
3970
- if (toolConfig != null && toolConfig.getSiteId().equals(siteId))
3971
- {
3972
- Map<String, Object> m = new HashMap<String, Object>();
3973
- Map<String, Object> ltiToolValues = m_ltiService.getTool(Long.valueOf(ltiToolId));
3974
- if ( ltiToolValues != null )
3975
- {
3976
- m.put("toolTitle", ltiToolValues.get(LTIService.LTI_TITLE));
3977
- m.put("pageTitle", ltiToolValues.get(LTIService.LTI_PAGETITLE));
3978
- m.put(LTIService.LTI_TITLE, (String) content.get(LTIService.LTI_TITLE));
3979
- m.put("contentKey", content.get(LTIService.LTI_ID));
3980
- linkedLtiContents.put(ltiToolId, m);
3951
+ } else {
3952
+ // Get tools specfic for this site or that are available in all sites.
3953
+ allTools = m_ltiService.getToolsDao(null, null, 0, 0, site.getId());
3954
+ }
3955
+ if (visibleTools != null && !visibleTools.isEmpty()) {
3956
+ HashMap<String, Map<String, Object>> ltiTools = new HashMap<>();
3957
+ HashMap<String, Map<String, Object>> linkedLtiContents = new HashMap<>();
3958
+ // Find the tools that exist in the site, this should only be done if we already have a site.
3959
+ if (site != null) {
3960
+ List<Map<String, Object>> contents = m_ltiService.getContentsDao(null, null, 0, 0, site.getId(), m_ltiService.isAdmin());
3961
+ for (Map<String, Object> content : contents) {
3962
+ String ltiToolId = content.get(m_ltiService.LTI_TOOL_ID).toString();
3963
+ String siteId = StringUtils.trimToNull((String) content.get(m_ltiService.LTI_SITE_ID));
3964
+ if (siteId != null) {
3965
+ // whether the tool is already enabled in site
3966
+ String pstr = (String) content.get(LTIService.LTI_PLACEMENT);
3967
+ if (StringUtils.trimToNull(pstr) != null) {
3968
+ // the lti tool is enabled in the site
3969
+ ToolConfiguration toolConfig = SiteService.findTool(pstr);
3970
+ if (toolConfig != null && toolConfig.getSiteId().equals(siteId)) {
3971
+ Map<String, Object> m = new HashMap<>();
3972
+ Map<String, Object> ltiToolValues = m_ltiService.getTool(Long.valueOf(ltiToolId));
3973
+ if (ltiToolValues != null) {
3974
+ m.put("toolTitle", ltiToolValues.get(LTIService.LTI_TITLE));
3975
+ m.put("pageTitle", ltiToolValues.get(LTIService.LTI_PAGETITLE));
3976
+ m.put(LTIService.LTI_TITLE, (String) content.get(LTIService.LTI_TITLE));
3977
+ m.put("contentKey", content.get(LTIService.LTI_ID));
3978
+ linkedLtiContents.put(ltiToolId, m);
3979
+ }
3981
3980
}
3982
3981
}
3983
3982
}
@@ -11624,8 +11623,7 @@ private boolean isSiteTypeInToolCategory(String siteType, Tool tool) {
11624
11623
11625
11624
11626
11625
/**
11627
- * getFeatures gets features for a new site
11628
- *
11626
+ * This is used after selecting a list of tools for a site to decide if we need to ask the user for options.
11629
11627
*/
11630
11628
private void getFeatures(ParameterParser params, SessionState state, String continuePageIndex) {
11631
11629
List idsSelected = new Vector();
0 commit comments