Skip to content

Commit

Permalink
SAK-46635 dashboards. Separate site icon and course image (sakaiproje…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Jan 12, 2024
1 parent dbb2b5a commit 4745489
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions kernel/api/src/main/java/org/sakaiproject/site/api/Site.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public interface Site extends Edit, Comparable, Serializable, AuthzGroup
*/
public final static String PROP_LTI_INBOUND_ROLE_MAP = "lti_inbound_role_map";

public final static String PROP_COURSE_IMAGE_URL = "course_image_url";

/**
* @return the user who created this.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public DashboardRestBean getSiteDashboard(@PathVariable String siteId) throws Us
bean.setTemplate((Integer) dashboardConfig.get("template"));
}
bean.setEditable(securityService.isSuperUser() || securityService.unlock(SiteService.SECURE_UPDATE_SITE, site.getReference()));
String imageUrl = site.getIconUrl();
String imageUrl = site.getProperties().getProperty(Site.PROP_COURSE_IMAGE_URL);
if (StringUtils.isBlank(imageUrl)) {
imageUrl = "/webcomponents/images/central_park_lamp.jpg";
}
Expand Down Expand Up @@ -329,16 +329,16 @@ public String saveSiteImage(HttpServletRequest req, @PathVariable String siteId)

ContentResourceEdit edit;
try {
edit = contentHostingService.editResource(collectionId + "site_icon_image.png");
edit = contentHostingService.editResource(collectionId + "course_image.png");
} catch (IdUnusedException | PermissionException e) {
edit = contentHostingService.addResource(collectionId, "site_icon_image", ".png", 1);
edit = contentHostingService.addResource(collectionId, "course_image", ".png", 1);
}
edit.setContent(fi.get());
edit.setContentLength(fi.getSize());
edit.setContentType(fi.getContentType());
contentHostingService.commitResource(edit, NotificationService.NOTI_NONE);
Site site = siteService.getSite(siteId);
site.setIconUrl(edit.getUrl());
site.getProperties().addProperty(Site.PROP_COURSE_IMAGE_URL, edit.getUrl());
siteService.save(site);
return edit.getUrl();
} catch (Exception e) {
Expand Down

0 comments on commit 4745489

Please sign in to comment.