Skip to content

Commit

Permalink
SAK-29873 allow non maintain role users to see unpublished sites in w…
Browse files Browse the repository at this point in the history
…orksite setup
  • Loading branch information
ktakacs committed Sep 17, 2015
1 parent 6786f6e commit 17b44fd
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ public boolean isIgnoreSoftlyDeleted()

/** Get any deleted sites, normally used by admin or purge job. */
public static final SelectionType ANY_DELETED = new SelectionType("anyDeleted", false, false, false, false);

/** Get unpublished sites the current user has access to */
public static final SelectionType INACTIVE_ONLY = new SelectionType("inactive", true, true, false, true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ private String getSitesWhere(SelectionType type, Object ofType, String criteria,

// if we are joining, start our where with the join clauses
StringBuilder where = new StringBuilder();
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED) || (type == SelectionType.PUBVIEW) || (type == SelectionType.INACTIVE_ONLY))
{
// join on site id and also select the proper user
where.append(siteServiceSql.getSitesWhere1Sql());
Expand Down Expand Up @@ -574,6 +574,10 @@ else if (ofType instanceof Set)
where.append(siteServiceSql.getSitesWhereNotSoftlyDeletedSql());
}

if (type == SelectionType.INACTIVE_ONLY) {
where.append(siteServiceSql.getUnpublishedSitesOnlySql());
}

// reject non-joinable sites
if (type == SelectionType.JOINABLE) where.append(siteServiceSql.getSitesWhere7Sql());
// check for pub view status
Expand Down Expand Up @@ -718,14 +722,14 @@ else if (ofType instanceof Set)
}
}
if (criteria != null) fieldCount += 1;
if ((type == SelectionType.JOINABLE) || (type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED)) fieldCount++;
if ((type == SelectionType.JOINABLE) || (type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED) || (type == SelectionType.PUBVIEW) || (type == SelectionType.INACTIVE_ONLY)) fieldCount++;
if (propertyCriteria != null) fieldCount += (2 * propertyCriteria.size());
Object fields[] = null;
if (fieldCount > 0)
{
fields = new Object[fieldCount];
int pos = 0;
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED) || (type == SelectionType.PUBVIEW) || (type == SelectionType.INACTIVE_ONLY))
{
fields[pos++] = getCurrentUserIdIfNull(userId);
}
Expand Down Expand Up @@ -803,7 +807,7 @@ private String getSitesJoin(SelectionType type, SortType sort )
{
// do we need a join?
String join = null;
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED) || (type == SelectionType.PUBVIEW) || (type == SelectionType.INACTIVE_ONLY))
{
// join with the SITE_USER table
join = siteServiceSql.getSitesJoin1Sql();
Expand Down Expand Up @@ -1180,7 +1184,7 @@ public int countSites(SelectionType type, Object ofType, String criteria, Map pr
{
// if we are joining, start our where with the join clauses
StringBuilder where = new StringBuilder();
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED) || (type == SelectionType.PUBVIEW) || (type == SelectionType.INACTIVE_ONLY))
{
// join on site id and also select the proper user
where.append(siteServiceSql.getSitesWhere1Sql());
Expand Down Expand Up @@ -1239,6 +1243,10 @@ else if (ofType instanceof Set)
where.append(siteServiceSql.getSitesWhereNotSoftlyDeletedSql());
}

if (type == SelectionType.INACTIVE_ONLY) {
where.append(siteServiceSql.getUnpublishedSitesOnlySql());
}

// reject non-joinable sites
if (type == SelectionType.JOINABLE) where.append(siteServiceSql.getSitesWhere7Sql());
// check for pub view status
Expand All @@ -1257,7 +1265,7 @@ else if (ofType instanceof Set)

// do we need a join?
String join = null;
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED) || (type == SelectionType.PUBVIEW) || (type == SelectionType.INACTIVE_ONLY))
{
// join with the SITE_USER table
join = siteServiceSql.getSitesJoin1Sql();
Expand Down Expand Up @@ -1295,14 +1303,14 @@ else if (ofType instanceof Set)
}
}
if (criteria != null) fieldCount += 1;
if ((type == SelectionType.JOINABLE) || (type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED)) fieldCount++;
if ((type == SelectionType.JOINABLE) || (type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED) || (type == SelectionType.PUBVIEW) || (type == SelectionType.INACTIVE_ONLY)) fieldCount++;
if (propertyCriteria != null) fieldCount += (2 * propertyCriteria.size());
Object fields[] = null;
if (fieldCount > 0)
{
fields = new Object[fieldCount];
int pos = 0;
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED) || (type == SelectionType.PUBVIEW) || (type == SelectionType.INACTIVE_ONLY))
{
fields[pos++] = sessionManager().getCurrentSessionUserId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,9 @@ public interface SiteServiceSql
* @return
*/
String getSitesWhereNotSoftlyDeletedSql();


/**
* returns part of the where clause to retrieve sites that are unpublished
*/
String getUnpublishedSitesOnlySql();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
* $Id: SiteServiceSqlDefault.java 3560 2007-02-19 22:08:01Z [email protected] $
***********************************************************************************
*
* Copyright (c) 2007, 2008 Sakai Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ECL-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright (c) 2007, 2008 Sakai Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ECL-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************************/

Expand Down Expand Up @@ -571,5 +571,11 @@ public String getSitesWhereNotSoftlyDeletedSql()
{
return "SAKAI_SITE.IS_SOFTLY_DELETED = '0' and ";
}


/**
* returns part of the where clause to retrieve sites that are unpublished
*/
public String getUnpublishedSitesOnlySql() {
return "SAKAI_SITE.PUBLISHED = '0' and ";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//SAK-29873
.unpublishedLabel {
opacity:0.2;
}
1 change: 1 addition & 0 deletions reference/library/src/morpheus-master/sass/tool.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@import "modules/tool/calendar/calendar";
@import "modules/tool/chat/chat";
@import "modules/tool/lessons/lessons";
@import "modules/tool/sitemanage/sitemanage";

@import "base/rtl";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#Java code
java.allmy = All My Sites
java.myActive = My Active Sites
java.myInactive = My Inactive Sites
java.my = My Workspace
### java.yoursite = Your site set up is complete. You may now add content to and then publish your site.
java.nosites = No site(s) checked. Please check a site or sites.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,11 @@ private String buildContextForTemplate(String preIndex, int index, VelocityPortl
if (state.getAttribute(STATE_VIEW_SELECTED) == null) {
state.setAttribute(STATE_VIEW_SELECTED, SiteConstants.SITE_TYPE_ALL);
}

if (ServerConfigurationService.getBoolean("sitesetup.show.unpublished", false) && !SecurityService.isSuperUser()) {
views.put(SiteConstants.SITE_ACTIVE, rb.getString("java.myActive"));
views.put(SiteConstants.SITE_INACTIVE, rb.getString("java.myInactive"));
}

// sort the keys in the views lookup
List<String> viewKeys = Collections.list(views.keys());
Expand Down Expand Up @@ -4780,6 +4785,14 @@ protected int sizeResources(SessionState state) {

String view = (String) state.getAttribute(STATE_VIEW_SELECTED);
if (view != null) {

org.sakaiproject.site.api.SiteService.SelectionType selectionType;
if (ServerConfigurationService.getBoolean("sitesetup.show.unpublished", false)) {
selectionType = org.sakaiproject.site.api.SiteService.SelectionType.MEMBER;
} else {
selectionType = org.sakaiproject.site.api.SiteService.SelectionType.ACCESS;
}

if (view.equals(SiteConstants.SITE_TYPE_ALL)) {
view = null;
// add my workspace if any
Expand All @@ -4794,8 +4807,8 @@ protected int sizeResources(SessionState state) {
}
size += SiteService
.countSites(
org.sakaiproject.site.api.SiteService.SelectionType.ACCESS,
null, search, null);
selectionType,
null, search, termProp);
} else if (view.equalsIgnoreCase(SiteConstants.SITE_TYPE_DELETED)) {
size += SiteService
.countSites(
Expand All @@ -4809,11 +4822,20 @@ protected int sizeResources(SessionState state) {
size++;
} catch (IdUnusedException e) {
}
} else if (view.equals(SiteConstants.SITE_ACTIVE)) {
view = null;
size += SiteService.countSites(
org.sakaiproject.site.api.SiteService.SelectionType.PUBVIEW,
view, search, termProp);
} else if (view.equals(SiteConstants.SITE_INACTIVE)) {
view = null;
size += SiteService.countSites(
org.sakaiproject.site.api.SiteService.SelectionType.INACTIVE_ONLY,
null, search, termProp);
} else {
// search for specific type of sites
size += SiteService
.countSites(
org.sakaiproject.site.api.SiteService.SelectionType.ACCESS,
size += SiteService.countSites(
selectionType,
view, search, termProp);
}
}
Expand Down Expand Up @@ -4925,6 +4947,15 @@ protected List readResourcesPage(SessionState state, int first, int last) {
}
String view = (String) state.getAttribute(STATE_VIEW_SELECTED);
if (view != null) {

org.sakaiproject.site.api.SiteService.SelectionType selectionType;

if (ServerConfigurationService.getBoolean("sitesetup.show.unpublished", false)) {
selectionType = org.sakaiproject.site.api.SiteService.SelectionType.MEMBER;
} else {
selectionType = org.sakaiproject.site.api.SiteService.SelectionType.ACCESS;
}

if (view.equals(SiteConstants.SITE_TYPE_ALL)) {
view = null;
// add my workspace if any
Expand All @@ -4940,7 +4971,7 @@ protected List readResourcesPage(SessionState state, int first, int last) {
rv
.addAll(SiteService
.getSites(
org.sakaiproject.site.api.SiteService.SelectionType.ACCESS,
selectionType,
null, search, termProp, sortType,
new PagingPosition(first, last)));
}
Expand All @@ -4957,12 +4988,20 @@ else if (view.equals(SiteConstants.SITE_TYPE_MYWORKSPACE)) {
null,
search, null, sortType,
new PagingPosition(first, last));
} else if (view.equals(SiteConstants.SITE_ACTIVE)) {
rv.addAll(SiteService.getSites(org.sakaiproject.site.api.SiteService.SelectionType.PUBVIEW,
null, search, termProp, sortType,
new PagingPosition(first, last)));
} else if (view.equals(SiteConstants.SITE_INACTIVE)) {
rv.addAll(SiteService.getSites(org.sakaiproject.site.api.SiteService.SelectionType.INACTIVE_ONLY,
null, search, termProp, sortType,
new PagingPosition(first, last)));
} else {
rv.addAll(SiteService
.getSites(
org.sakaiproject.site.api.SiteService.SelectionType.ACCESS,
view, search, termProp, sortType,
new PagingPosition(first, last)));
.getSites(
selectionType,
view, search, termProp, sortType,
new PagingPosition(first, last)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,3 +891,8 @@ dl.defList dd{
{
margin-bottom: 1em;
}

/* SAK-29873 */
.unpublishedLabel {
opacity:0.2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,16 @@
#end
</td>
<td headers="title">
#if (!$service.allowAccessSite($site.Id))
<label class="unpublishedLabel">$validator.escapeHtml($site.getTitle())</label>
#else
<a href="$site.Url" target="_top">
$validator.escapeHtml($site.getTitle())
</a>
<a href="#" id="$site.Id" class="getSiteDesc" title="$tlang.getString('list.moreinfotooltip')">
<img src="#imageLink("sakai/information_gray.png")" border="0" title ="$tlang.getString('list.moreinfotooltip')" alt ="$tlang.getString('list.moreinfotooltip')" />
</a>
#end
<a href="#" id="$site.Id" class="getSiteDesc" title="$tlang.getString('list.moreinfotooltip')">
<img src="#imageLink("sakai/information_gray.png")" border="0" title ="$tlang.getString('list.moreinfotooltip')" alt ="$tlang.getString('list.moreinfotooltip')" />
</a>
</td>
#if($show_id_column)
<td headers="id">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ public class SiteConstants {
public final static String SITE_TYPE_DELETED = "site_type_deleted";

public final static String SITE_TYPE_ALL = "site_type_all";

public final static String SITE_ACTIVE = "pubView";

public final static String SITE_INACTIVE = "inactive";
}

0 comments on commit 17b44fd

Please sign in to comment.