CiviCasesでアクティビティのグループ化値にアクセスするにはどうすればよいですか?
テストシステムで既存のCiviCRMデータベースの一部の機能を変更しようとしただけです(CiviCasesを使用)。ですから、私はまだ初心者です。これがばかげた質問である場合は申し訳ありませんが、ヒントをいただければ幸いです:)
グループ化値が「system」のすべてのアクティビティをケースビューから除外する機能を含めたいと思います。現在、ケースビューは、ユーザーに関係のないアクティビティでスパムされています(たとえば、「ケースタイプが...から...に変更されました」)。アクティビティには、civicrm_option_valueというテーブルでこのグループ化値が与えられます。
So I suppose I have to include some filter into the file /civicrm/CRM/Case/Form/CaseView.php, accessing each activity's grouping and testing it for "system". Can you give me any hint how I can access the activities' grouping value?
Thanks in advance, emma
回答
The function that is responsible to build the list of activities on case is CRM_Case_BAO_Case::getCaseActivity(). It is very difficult to alter the function via custom module/plugin/extension.
I would create an extension that would alter the page callback for 'civicrm/ajax/activity' to custom function (eg CRM_ExtName_Page_AJAX::getCaseActivity using hook_civicrm_alterMenu hook. Copy CRM_Activity_Page_AJAX::getCaseActivity() into your custom php file i.e CRM_ExtName_Page_AJAX::getCaseActivity() and change the line below line to your custom function which will basically copy paste of CRM_Case_BAO_Case::getCaseActivity function with change the where clause to include your conditions
$activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);
HTH
Pradeep
In the end, I directly changed the CRM_Case_BAO_Case::getCaseActivity function instead of creating an extension.
Specifically, I changed this function's $where variable to:
$where = "
WHERE cca.case_id= %1
AND ca.is_current_revision = 1
AND cov.grouping = 'visible'";
Here, "cov" is the alias for the table civicrm_option_value. The alias is already predefined in the $from variable above.
I added the grouping value "visible" manually in the database to those activities that should be visible in the case view.
I've posted almost exactly the same question and got some pretty helpful answers.
Especially the extension mentioned here seems to be really useful (I have not tried it yet, though).