Skip to content

Commit b74a820

Browse files
buckettottenhoff
authored andcommitted
SAK-31836 Don't preselect LTI tools in site (sakaiproject#3455)
* SAK-31836 Remove unused template file in site-info While looking at how LTI tools were displayed I found that there are no references to this file in the codebase and I can’t even find any references to it in the history. It came in as party of SAK-16600 but doesn’t look to have ever been used. * SAK-31836 Don’t pre-select LTI tools in Worksite Setup When editing an existing site through worksite setup if the tool is already placed in a second site then it gets automatically added when editing any other site.
1 parent 50f022f commit b74a820

File tree

2 files changed

+33
-199
lines changed

2 files changed

+33
-199
lines changed

site-manage/site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java

+33-35
Original file line numberDiff line numberDiff line change
@@ -2864,7 +2864,8 @@ public int compare(JoinableGroup g1, JoinableGroup g2){
28642864
case 26:
28652865
/*
28662866
* 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.
28682869
*/
28692870
site_type = (String) state.getAttribute(STATE_SITE_TYPE);
28702871
boolean existingSite = site != null ? true : false;
@@ -3945,39 +3946,37 @@ private void buildLTIToolContextForTemplate(Context context,
39453946
List<Map<String, Object>> visibleTools, allTools;
39463947
// get the visible and all (including stealthed) list of lti tools
39473948
visibleTools = m_ltiService.getTools(null,null,0,0);
3948-
if (site == null)
3949+
if (site == null) {
39493950
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+
}
39813980
}
39823981
}
39833982
}
@@ -11624,8 +11623,7 @@ private boolean isSiteTypeInToolCategory(String siteType, Tool tool) {
1162411623

1162511624

1162611625
/**
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.
1162911627
*/
1163011628
private void getFeatures(ParameterParser params, SessionState state, String continuePageIndex) {
1163111629
List idsSelected = new Vector();

site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/toolListDisplay.vm

-164
This file was deleted.

0 commit comments

Comments
 (0)