forked from civicrm/org.civicrm.civicase
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIVIMM-261: Support automatic email filing for case type categories o…
…ther than cases
- Loading branch information
Muhammad Shahrukh
committed
Jan 16, 2025
1 parent
9230a07
commit 71a22c3
Showing
4 changed files
with
71 additions
and
85 deletions.
There are no files selected for viewing
79 changes: 0 additions & 79 deletions
79
CRM/Civicase/Hook/alterMailParams/SubjectCaseTypeCategoryProcessor.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/** | ||
* Remove word 'case' in email subject. | ||
*/ | ||
class CRM_Civicase_Hook_alterMailParams_SubjectProcessor { | ||
|
||
/** | ||
* A substring of email subject that should be removed. | ||
* | ||
* @var string | ||
* This substring will be removed. | ||
*/ | ||
private $toRemove = '[case '; | ||
|
||
/** | ||
* Email subject processor. | ||
* | ||
* Remove word 'case' in email subject. | ||
* | ||
* @param array $params | ||
* Mail parameters. | ||
* @param string $context | ||
* Mail context. | ||
*/ | ||
public function run(array &$params, $context) { | ||
$caseId = CRM_Utils_Request::retrieve('caseid', 'Integer'); | ||
if (!$this->shouldRun($params, $context, $caseId)) { | ||
return; | ||
} | ||
|
||
// Make sure we make just 1 replacement. | ||
$subject = explode($this->toRemove, $params['subject'], 2); | ||
$params['subject'] = '[' . $subject[1]; | ||
} | ||
|
||
/** | ||
* Determines if the hook will run. | ||
* | ||
* @param array $params | ||
* Mail parameters. | ||
* @param string $context | ||
* Mail context. | ||
* @param int $caseId | ||
* Case id. | ||
* | ||
* @return bool | ||
* returns TRUE if hook should run, FALSE otherwise. | ||
*/ | ||
private function shouldRun(array $params, $context, $caseId) { | ||
if (empty($params['subject'])) { | ||
return FALSE; | ||
} | ||
// If case id is set and email subject starts with '[case '. | ||
return $caseId && strpos($params['subject'], $this->toRemove) === 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters