Skip to content

Commit

Permalink
SAK-32767 Allow admins to set the new Site ID when duplicating sites …
Browse files Browse the repository at this point in the history
…from Site Info (sakaiproject#4684)
  • Loading branch information
ddelblanco authored and ottenhoff committed Aug 21, 2017
1 parent 8a81412 commit 8840983
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,8 @@ sitdup.dupsit = Duplicate site
sitdup.dupsit2 = Duplicated site
sitdup.hasbeedup = has been created.
sitdup.sitti = Site Title
sitdup.newsitid = Site ID
sitdup.idused = The ID is being used by an existing site, please input a different ID or leave the field empty to allow the system to generate a new random ID
sitdup.duptit = Retain Resources file storage quota?
sitdup.curquot = Currently set to
sitdup.yesdupequota = Yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3277,7 +3277,7 @@ public int compare(String s1, String s2) {
context.put("duplicatedName", state
.getAttribute(SITE_DUPLICATED_NAME));
}

context.put( CONTEXT_IS_ADMIN, SecurityService.isSuperUser() );
// Add option to also copy ScoringComponent associations
ScoringService scoringService = (ScoringService) ComponentManager.get("org.sakaiproject.scoringservice.api.ScoringService");
ScoringAgent scoringAgent = scoringService.getDefaultScoringAgent();
Expand All @@ -3301,6 +3301,7 @@ public int compare(String s1, String s2) {
}

context.put("titleMaxLength", state.getAttribute(STATE_SITE_TITLE_MAX));
context.put("siteIdMaxLength", 99);
return (String) getContext(data).get("template") + TEMPLATE[29];
case 36:
/*
Expand Down Expand Up @@ -9667,13 +9668,21 @@ public void run() {
*/
if (forward) {
if (state.getAttribute(SITE_DUPLICATED) == null) {
if (StringUtils.trimToNull(params.getString("title")) == null) {
addAlert(state, rb.getString("java.dupli") + " ");
if ((SecurityService.isSuperUser())&& ((StringUtils.trimToNull(params.getString("newSiteId")) != null)&&(SiteService.siteExists(params.getString("newSiteId"))))){
addAlert(state, rb.getString("sitdup.idused") + " ");
} else if (StringUtils.trimToNull(params.getString("title")) == null) {
addAlert(state, rb.getString("java.dupli") + " ");
} else {
String title = params.getString("title");
state.setAttribute(SITE_DUPLICATED_NAME, title);

String newSiteId = IdManager.createUuid();
String newSiteId = null;
if (StringUtils.trimToNull(params.getString("newSiteId")) == null) {
newSiteId = IdManager.createUuid();
} else{
newSiteId = params.getString("newSiteId");
}

try {
String oldSiteId = (String) state
.getAttribute(STATE_SITE_INSTANCE_ID);
Expand All @@ -9692,7 +9701,7 @@ public void run() {

// SAK-20797
long oldSiteQuota = this.getSiteSpecificQuota(oldSiteId);

Site site = SiteService.addSite(newSiteId,
getStateSite(state));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
<input type="text" name="title" id="title" maxlength="$!titleMaxLength" size="20" value="" />
</div>
</div>
#if ($!isAdmin)
<div class="form-group row">
<label for="newSIteId" class="col-sm-2 form-control-label">
$tlang.getString("sitdup.newsitid")
</label>
<div class="col-sm-6">
<input type="text" name="newSiteId" id="newSiteId" maxlength="$!siteIdMaxLength" size="50" value="" />
</div>
</div>
#end
#if ($canSelect)
#if ($allowUnmanaged)
<p class="checkbox indnt1">
Expand Down

0 comments on commit 8840983

Please sign in to comment.