Commit f5d49c6a authored by ErikHommel's avatar ErikHommel
Browse files

fix issues 7276 and 6386

parent e8d44d09
......@@ -55,7 +55,13 @@ class CRM_Nbrprojectvolunteerlist_NbrParticipation {
$mspCsId = $msp->getCsId();
if (isset($searchFormValues['csid']) && (int) $searchFormValues['csid'] == $mspCsId) {
if (isset($searchFormValues['study_id'])) {
$caseIds = [];
$studyId = (int) $searchFormValues['study_id'];
foreach ($form->_contactIds as $contactId) {
$caseIds[$contactId] = CRM_Nihrbackbone_NbrVolunteerCase::getActiveParticipationCaseId($studyId, $contactId);
}
$session = CRM_Core_Session::singleton();
$session->nbr_email_pdf_case_ids = $caseIds;
$form->removeElement('campaign_id');
$form->add('hidden', 'study_id');
$form->setDefaults(['study_id' => $studyId]);
......@@ -145,8 +151,9 @@ class CRM_Nbrprojectvolunteerlist_NbrParticipation {
* @param $activityId
* @param $activityTypeId
*/
public static function fileActivityOnCases($activityId, $activityTypeId, $invite = FALSE) {
public static function fileActivityOnCases($activityId, $activityTypeId) {
$caseIds = [];
$fileOnCase = TRUE;
$session = CRM_Core_Session::singleton();
if ($activityTypeId == Civi::service('nbrBackbone')->getEmailActivityTypeId() || $activityTypeId == Civi::service('nbrBackbone')->getLetterActivityTypeId()) {
if (isset($session->nbr_email_pdf_case_ids)) {
......@@ -155,17 +162,31 @@ class CRM_Nbrprojectvolunteerlist_NbrParticipation {
}
if (!empty($caseIds)) {
foreach ($caseIds as $caseContactId => $caseId) {
$insert = "INSERT INTO civicrm_case_activity (case_id, activity_id) VALUES(%1, %2)";
CRM_Core_DAO::executeQuery($insert, [
1 => [(int) $caseId, "Integer"],
2 => [(int) $activityId, "Integer"],
]);
// if PPF, check if invite processing required
// only if contact is OK for PDF activity!
if ($activityTypeId == Civi::service('nbrBackbone')->getLetterActivityTypeId()) {
$studyId = CRM_Utils_Request::retrieveValue('study_id', 'Integer');
$isInvite = CRM_Utils_Request::retrieveValue('is_nbr_invite', 'Boolean');
if ($studyId && $isInvite) {
CRM_Nihrbackbone_NbrInvitation::addInviteActivity($caseId, $caseContactId, $studyId, "invite by letter");
$fileOnCase = FALSE;
$query = "SELECT contact_id FROM civicrm_activity_contact WHERE activity_id = %1 AND record_type_id = %2";
$activityTargetId = CRM_Core_DAO::singleValueQuery($query, [
1 => [(int) $activityId, 'Integer'],
2 => [Civi::service('nbrBackbone')->getTargetRecordTypeId(), 'Integer'],
]);
if ($activityTargetId == $caseContactId) {
$fileOnCase = TRUE;
}
}
if ($fileOnCase) {
$insert = "INSERT INTO civicrm_case_activity (case_id, activity_id) VALUES(%1, %2)";
CRM_Core_DAO::executeQuery($insert, [
1 => [(int) $caseId, "Integer"],
2 => [(int) $activityId, "Integer"],
]);
// if PPF, check if invite processing required
if ($activityTypeId == Civi::service('nbrBackbone')->getLetterActivityTypeId()) {
$studyId = CRM_Utils_Request::retrieveValue('study_id', 'Integer');
$isInvite = CRM_Utils_Request::retrieveValue('is_nbr_invite', 'Boolean');
if ($studyId && $isInvite) {
CRM_Nihrbackbone_NbrInvitation::addInviteActivity($caseId, $caseContactId, $studyId, "invite by letter");
}
}
}
}
......
......@@ -54,14 +54,6 @@ class CRM_Nbrprojectvolunteerlist_Utils {
return "nbr_cs_volunteerlist_qfkey_" . CRM_Core_Session::getLoggedInContactID();
}
/**
* Method to get the filter setting name for the logged in user
* @return string
*/
public static function getFilterSettingName() {
return "nbr_cs_volunteerlist_filters_" . CRM_Core_Session::getLoggedInContactID();
}
/**
* Method to get all non-workflow active message templates
*
......
......@@ -14,7 +14,7 @@
<url desc="Support">https://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-12-03</releaseDate>
<releaseDate>2020-12-09</releaseDate>
<version>1.27</version>
<develStage>beta</develStage>
<compatibility>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment