Skip to content

Commit

Permalink
Merge pull request sakaiproject#1696 from ddelblanco/SAK-30309
Browse files Browse the repository at this point in the history
SAK-30309 Filter all the  sites and not only the ones from the user
  • Loading branch information
ottenhoff committed Feb 20, 2016
2 parents cb1acc7 + 4e36076 commit 35e8b74
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,18 @@ public int publishCourseSites(int numDaysBeforeTermStarts) {
// get a list of all published and unpublished course sites in ascending creation date order which are associated with the specified academic session
Hashtable<String, String> propertyCriteria = new Hashtable<String, String>();
propertyCriteria.put("term_eid", academicSession.getEid());
List<String> sites = (List<String>)siteService.getSiteIds(SelectionType.INACTIVE_ONLY, "course", null, propertyCriteria, SortType.CREATED_ON_ASC, null);
//We only will check COURSES with the right term_eid property. We will filter later if they are or not published
List<String> sites = (List<String>)siteService.getSiteIds(SelectionType.ANY, "course", null, propertyCriteria, SortType.CREATED_ON_ASC, null);

for(String siteId : sites) {
//site.loadAll();
// see if this service has already published course site once before.
// if it has, then someone has manually reset the published flag, and wants the course to be unpublished.
// so don't switch it back to being published - just leave it as unpublished.
// ResourceProperties siteProperties = site.getProperties();
Site site = siteService.getSite(siteId);
ResourcePropertiesEdit siteProperties = site.getPropertiesEdit();
String siteProperty = siteProperties.getProperty(SITE_PROPERTY_COURSE_SITE_PUBLISHED);
//We will check only unpublished sites and not softlyDeleted
if (!site.isPublished() && (!site.isSoftlyDeleted())) {
ResourcePropertiesEdit siteProperties = site.getPropertiesEdit();
String siteProperty = siteProperties.getProperty(SITE_PROPERTY_COURSE_SITE_PUBLISHED);

if (!"set".equals(siteProperty)) {
// check permissions
Expand All @@ -220,6 +221,7 @@ public int publishCourseSites(int numDaysBeforeTermStarts) {
numSitesPublished++;
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,33 +172,37 @@ public int removeCourseSites(CourseSiteRemovalService.Action action, int numDays
// get a list of all published course sites in ascending creation date order which are associated with the specified academic session
Hashtable<String, String> propertyCriteria = new Hashtable<String, String>();
propertyCriteria.put("term_eid", academicSession.getEid());
List<String> sites = (List<String>)siteService.getSiteIds(SelectionType.PUBVIEW, "course", null, propertyCriteria, SortType.CREATED_ON_ASC, null);
//We only will check COURSES with the right term_eid property. We will filter later if they are or not published
List<String> sites = (List<String>)siteService.getSiteIds(SelectionType.ANY, "course", null, propertyCriteria, SortType.CREATED_ON_ASC, null);

for(String siteId : sites) {
// see if this service has already removed/unpublished this course site once before.
// see if this service has already removed/unpublished this course site once before.
// if it has, then someone has manually published the site, and wants the course to be published.
// so don't switch it back to being unpublished - just leave it as published.
Site site = siteService.getSite(siteId);
ResourcePropertiesEdit siteProperties = site.getPropertiesEdit();
String siteProperty = siteProperties.getProperty(SITE_PROPERTY_COURSE_SITE_REMOVAL);
if (!"set".equals(siteProperty)) {
// check permissions

if (!checkPermission(PERMISSION_COURSE_SITE_REMOVAL, site.getId())) {
logger.error("You do not have permission to " + action + " the " + site.getTitle() + " course site (" + site.getId() + ").");
} else if (action == CourseSiteRemovalService.Action.remove) {
// remove the course site
logger.debug(action + "removing course site " + site.getTitle() + " (" + site.getId() + ").");
siteService.removeSite(site);
} else {
// unpublish the course site
logger.debug("unpublishing course site " + site.getTitle() + " (" + site.getId() + ").");
siteProperties.addProperty(SITE_PROPERTY_COURSE_SITE_REMOVAL, "set");
site.setPublished(false);
siteService.save(site);
}
numSitesRemoved++;
//we only need to check published sites and not softlyDeleted.
if (site.isPublished() && (!site.isSoftlyDeleted())) {
ResourcePropertiesEdit siteProperties = site.getPropertiesEdit();
String siteProperty = siteProperties.getProperty(SITE_PROPERTY_COURSE_SITE_REMOVAL);
if (!"set".equals(siteProperty)) {
// check permissions

if (!checkPermission(PERMISSION_COURSE_SITE_REMOVAL, site.getId())) {
logger.error("You do not have permission to " + action + " the " + site.getTitle() + " course site (" + site.getId() + ").");
} else if (action == CourseSiteRemovalService.Action.remove) {
// remove the course site
logger.debug(action + "removing course site " + site.getTitle() + " (" + site.getId() + ").");
siteService.removeSite(site);
} else {
// unpublish the course site
logger.debug("unpublishing course site " + site.getTitle() + " (" + site.getId() + ").");
siteProperties.addProperty(SITE_PROPERTY_COURSE_SITE_REMOVAL, "set");
site.setPublished(false);
siteService.save(site);
}
numSitesRemoved++;

}
}
}
}
Expand Down

0 comments on commit 35e8b74

Please sign in to comment.