Skip to content

Commit

Permalink
Merge pull request sakaiproject#135 from ottenhoff/KNL-1023
Browse files Browse the repository at this point in the history
KNL-1023 new SelectionType that provides published and unpublished member sites
  • Loading branch information
ottenhoff committed Feb 9, 2015
2 parents 5d738d0 + f096350 commit c78ec99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ public boolean isIgnoreSoftlyDeleted()

/** Get any non-user sites. */
public static final SelectionType NON_USER = new SelectionType("nonUser", false, true, false, true);

/** Get sites that the current user is a member of regardless whether site is published */
public static final SelectionType MEMBER = new SelectionType("member", true, true, false, true);

/** Get my deleted sites. */
public static final SelectionType DELETED = new SelectionType("deleted", true, true, true, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,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.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
{
// join on site id and also select the proper user
where.append(siteServiceSql.getSitesWhere1Sql());
Expand Down Expand Up @@ -728,14 +728,14 @@ else if (ofType instanceof Set)
}
}
if (criteria != null) fieldCount += 1;
if ((type == SelectionType.JOINABLE) || (type == SelectionType.ACCESS) || (type == SelectionType.UPDATE)) fieldCount++;
if ((type == SelectionType.JOINABLE) || (type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER)) 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.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
{
fields[pos++] = getCurrentUserIdIfNull(userId);
}
Expand Down Expand Up @@ -813,7 +813,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.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
{
// join with the SITE_USER table
join = siteServiceSql.getSitesJoin1Sql();
Expand Down Expand Up @@ -1190,7 +1190,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.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
{
// join on site id and also select the proper user
where.append(siteServiceSql.getSitesWhere1Sql());
Expand Down Expand Up @@ -1267,7 +1267,7 @@ else if (ofType instanceof Set)

// do we need a join?
String join = null;
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
{
// join with the SITE_USER table
join = siteServiceSql.getSitesJoin1Sql();
Expand Down Expand Up @@ -1305,14 +1305,14 @@ else if (ofType instanceof Set)
}
}
if (criteria != null) fieldCount += 1;
if ((type == SelectionType.JOINABLE) || (type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.DELETED)) fieldCount++;
if ((type == SelectionType.JOINABLE) || (type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED)) 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.DELETED))
if ((type == SelectionType.ACCESS) || (type == SelectionType.UPDATE) || (type == SelectionType.MEMBER) || (type == SelectionType.DELETED))
{
fields[pos++] = sessionManager().getCurrentSessionUserId();
}
Expand Down

0 comments on commit c78ec99

Please sign in to comment.