Skip to content

Commit

Permalink
Merge pull request #518 from SalesforceFoundation/feature/240
Browse files Browse the repository at this point in the history
240 to Main
  • Loading branch information
davidmreed committed Jul 22, 2022
2 parents 2e39505 + 14504ff commit fb835a2
Show file tree
Hide file tree
Showing 17 changed files with 1,705 additions and 102 deletions.
5 changes: 5 additions & 0 deletions src/classes/DatabaseDml.cls
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
This class was created for situations where we need to run in system
mode.
*/
/* sfge-disable ApexFlsViolationRule */
public without sharing virtual class DatabaseDml {

protected DatabaseDml() {}
Expand Down
2 changes: 1 addition & 1 deletion src/classes/SoqlListView.cls
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public with sharing class SoqlListView extends ComponentControllerBase {

// action method to delete an item from the database.
public PageReference DeleteItem() {
if (idDeleteItem != null) {
if (idDeleteItem != null && idDeleteItem.getSObjectType().getDescribe().isDeletable()) {
database.delete(idDeleteItem);
idDeleteItem = null;
setCon = null;
Expand Down
37 changes: 36 additions & 1 deletion src/classes/VOL_Access.cls
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
/*
Copyright (c) 2022, Salesforce.org
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Salesforce.org nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
This class checks to see if the current user is a guest site user and
whether or not the admin has elevated the guest site user access. All
permission checks are expected to be done by the caller.
*/
/* sfge-disable ApexFlsViolationRule */
public with sharing virtual class VOL_Access {
protected VOL_Access() {}

Expand Down Expand Up @@ -55,7 +90,7 @@ public with sharing virtual class VOL_Access {
}

/**
* @description Calls the update check to verify the users create access
* @description Calls the create check to verify the users create access
*/
public void checkCreateAccess(String objectName, Set<String> fieldNames) {
UTIL_Describe.checkCreateAccess(objectName, fieldNames);
Expand Down
70 changes: 49 additions & 21 deletions src/classes/VOL_CTRL_JobCalendar.cls
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ global with sharing class VOL_CTRL_JobCalendar {
if (p != null && p != '') {
// Ensure the user has access to the object and fields before querying
UTIL_Describe.checkReadAccess('Campaign', new Set<String>{'Id', 'StartDate'});

// Using a dynamic describe access check in the method called above.
/* sfge-disable-next-line ApexFlsViolationRule */
list<Campaign> listCampaign = [select Id, StartDate from Campaign where Id = :p];
if (listCampaign.size() > 0) {
initialDate = Date.valueOf(listCampaign[0].StartDate);
Expand All @@ -70,7 +71,8 @@ global with sharing class VOL_CTRL_JobCalendar {
new Set<String>{'Id',
UTIL_Describe.StrTokenNSPrefix('First_Shift__c'),
UTIL_Describe.StrTokenNSPrefix('Campaign__c')});

// Using a dynamic describe access check in the method called above.
/* sfge-disable-next-line ApexFlsViolationRule */
list<Volunteer_Job__c> listJob = [select Id, First_Shift__c, Campaign__c
from Volunteer_Job__c where Id = :p];
if (listJob.size() > 0) {
Expand All @@ -91,7 +93,10 @@ global with sharing class VOL_CTRL_JobCalendar {
new Set<String>{'Id',
UTIL_Describe.StrTokenNSPrefix('Start_Date_Time__c'),
UTIL_Describe.StrTokenNSPrefix('Volunteer_Job__c')});

UTIL_Describe.checkReadAccess(UTIL_Describe.StrTokenNSPrefix('Volunteer_Job__c'),
new Set<String>{UTIL_Describe.StrTokenNSPrefix('Campaign__c')});
// Using a dynamic describe access check in the method called above.
/* sfge-disable-next-line ApexFlsViolationRule */
list<Volunteer_Shift__c> listShift = [select Id, Start_Date_Time__c,
Volunteer_Job__c, Volunteer_Job__r.Campaign__c
from Volunteer_Shift__c where Id = :p];
Expand Down Expand Up @@ -157,6 +162,8 @@ global with sharing class VOL_CTRL_JobCalendar {

// only specify the css file if in the web page scenario.
if (strURLtoCSSFile == null && fWeb) {
// System query to find the css doc if the admin has added it for custom css
/* sfge-disable-next-line ApexFlsViolationRule */
list<Document> listDocs = [SELECT Name, Id From Document WHERE Name = 'JobCalendarCSS.css' LIMIT 1 ];
if (listDocs.size() > 0) {
Document doc = listDocs[0];
Expand Down Expand Up @@ -193,11 +200,17 @@ global with sharing class VOL_CTRL_JobCalendar {
get {
list<SelectOption> listSO = new list<SelectOption>();
listSO.add(new SelectOption('', system.label.labelChoiceAllActiveCampaigns));
for (Campaign c : [select Name, Id, StartDate from Campaign
where RecordTypeId = :VOL_SharedCode.recordtypeIdVolunteersCampaign
and IsActive = true order by Name asc limit 999]) {
listSO.add(new SelectOption(c.id, c.name));
}
if (Campaign.SObjectType.getDescribe().isAccessible() && Campaign.Name.getDescribe().isAccessible() &&
Campaign.IsActive.getDescribe().isAccessible() && Campaign.StartDate.getDescribe().isAccessible() &&
Campaign.RecordTypeId.getDescribe().isAccessible()) {
for (Campaign c : [select Name, Id, StartDate from Campaign
where RecordTypeId = :VOL_SharedCode.recordtypeIdVolunteersCampaign
and IsActive = true order by Name asc limit 999]) {
listSO.add(new SelectOption(c.id, c.name));
}
}

// Allow the page to load without options.
return listSO;
}
set;
Expand All @@ -223,17 +236,25 @@ global with sharing class VOL_CTRL_JobCalendar {
get {
list<SelectOption> listSO = new list<SelectOption>();
listSO.add(new SelectOption('', system.label.labelChoiceAllJobs));
if (campaignId == null) {
for (Volunteer_Job__c vj : [select Name, Id from Volunteer_Job__c
where Campaign__r.IsActive = true order by name limit 999]) {
listSO.add(new SelectOption(vj.id, vj.name));
}
} else {
for (Volunteer_Job__c vj : [select Name, Id from Volunteer_Job__c
where Campaign__c = :campaignId order by name limit 999]) {
listSO.add(new SelectOption(vj.id, vj.name));
}
}
if (Volunteer_Job__c.SObjectType.getDescribe().isAccessible() && Volunteer_Job__c.Campaign__c.getDescribe().isAccessible()
&& Campaign.SObjectType.getDescribe().isAccessible() && Campaign.IsActive.getDescribe().isAccessible()) {
if (campaignId == null) {
// Using a dynamic describe access check in the method called above.
/* sfge-disable-next-line ApexFlsViolationRule */
for (Volunteer_Job__c vj : [select Name, Id from Volunteer_Job__c
where Campaign__r.IsActive = true order by name limit 999]) {
listSO.add(new SelectOption(vj.id, vj.name));
}
} else {
// Using a dynamic describe access check in the method called above.
/* sfge-disable-next-line ApexFlsViolationRule */
for (Volunteer_Job__c vj : [select Name, Id from Volunteer_Job__c
where Campaign__c = :campaignId order by name limit 999]) {
listSO.add(new SelectOption(vj.id, vj.name));
}
}
} // Allow the page to load without options

return listSO;
}

Expand Down Expand Up @@ -367,8 +388,15 @@ global with sharing class VOL_CTRL_JobCalendar {
UTIL_Describe.StrTokenNSPrefix('Total_Volunteers__c'),
UTIL_Describe.StrTokenNSPrefix('Number_of_Volunteers_Still_Needed__c'),
UTIL_Describe.StrTokenNSPrefix('Description__c')});
UTIL_Describe.checkReadAccess(UTIL_Describe.StrTokenNSPrefix('Volunteer_Job__c'),
new Set<String>{'Name',
UTIL_Describe.StrTokenNSPrefix('Campaign__c'),
UTIL_Describe.StrTokenNSPrefix('Display_On_Website__c'),
UTIL_Describe.StrTokenNSPrefix('Volunteer_Website_Time_Zone__c')});
UTIL_Describe.checkReadAccess('Campaign',
new Set<String>{UTIL_Describe.StrTokenNSPrefix('Volunteer_Website_Time_Zone__c')});

if (!fAllJob) {
if (!fAllJob) {
listShifts = [select Id, Name, Volunteer_Job__c, Volunteer_Job__r.Name, Volunteer_Job__r.Volunteer_Website_Time_Zone__c, Volunteer_Job__r.Campaign__r.Volunteer_Website_Time_Zone__c,
Volunteer_Job__r.Campaign__c, Start_Date_Time__c, Duration__c,
Total_Volunteers__c, Number_of_Volunteers_Still_Needed__c, Description__c
Expand All @@ -378,6 +406,7 @@ global with sharing class VOL_CTRL_JobCalendar {
and (Volunteer_Job__r.Display_On_Website__c = true or Volunteer_Job__r.Display_On_Website__c = :fWeb)
order by Start_Date_Time__c asc];
} else if (fAllCampaign && fAllJob) {
UTIL_Describe.checkReadAccess('Campaign', new Set<String>{'IsActive'});
listShifts = [select Id, Name, Volunteer_Job__c, Volunteer_Job__r.Name, Volunteer_Job__r.Volunteer_Website_Time_Zone__c,Volunteer_Job__r.Campaign__r.Volunteer_Website_Time_Zone__c,
Volunteer_Job__r.Campaign__c, Start_Date_Time__c, Duration__c,
Total_Volunteers__c, Number_of_Volunteers_Still_Needed__c, Description__c
Expand All @@ -391,7 +420,6 @@ global with sharing class VOL_CTRL_JobCalendar {
if (fShowCampaignHierarchy) {
listCampaignIds = VOL_SharedCode.listIdsCampaignsInHierarchy(strCampaignId);
}

listShifts = [select Id, Name, Volunteer_Job__c, Volunteer_Job__r.Name, Volunteer_Job__r.Volunteer_Website_Time_Zone__c,Volunteer_Job__r.Campaign__r.Volunteer_Website_Time_Zone__c,
Volunteer_Job__r.Campaign__c, Start_Date_Time__c, Duration__c,
Total_Volunteers__c, Number_of_Volunteers_Still_Needed__c, Description__c
Expand Down

0 comments on commit fb835a2

Please sign in to comment.