From 44f817d4374541d59ec68ab29226ef5d592ccbc2 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 15 Aug 2017 11:18:33 +0100 Subject: [PATCH 1/2] Replace some CRM_Core_OptionGroup::values with CRM_Activity_BAO_ActivityContact::buildOptions --- CRM/Activity/ActionMapping.php | 2 +- CRM/Activity/BAO/Activity.php | 30 +++++++++---------- CRM/Activity/BAO/ActivityAssignment.php | 6 ++-- CRM/Activity/BAO/ActivityTarget.php | 6 ++-- CRM/Activity/BAO/Query.php | 4 +-- CRM/Activity/Form/Activity.php | 2 +- CRM/Activity/Form/Task.php | 2 +- CRM/Activity/Form/Task/PickOption.php | 2 +- .../Form/Task/SearchTaskHookSample.php | 2 +- CRM/Activity/Page/AJAX.php | 2 +- CRM/Activity/Selector/Search.php | 2 +- CRM/Campaign/BAO/Petition.php | 8 ++--- CRM/Campaign/BAO/Query.php | 2 +- CRM/Campaign/BAO/Survey.php | 6 ++-- CRM/Case/BAO/Case.php | 6 ++-- CRM/Case/BAO/Query.php | 2 +- CRM/Case/Form/Activity.php | 2 +- CRM/Case/Form/ActivityView.php | 2 +- CRM/Case/XMLProcessor/Process.php | 2 +- CRM/Case/XMLProcessor/Report.php | 6 ++-- CRM/Contact/BAO/Contact/Utils.php | 2 +- CRM/Contact/BAO/Query.php | 4 +-- .../Form/Search/Custom/ActivitySearch.php | 2 +- CRM/Contact/Form/Task/SMSCommon.php | 2 +- CRM/Contribute/BAO/Contribution.php | 2 +- CRM/Friend/BAO/Friend.php | 2 +- CRM/Logging/Differ.php | 2 +- CRM/Mailing/BAO/MailingJob.php | 2 +- CRM/Report/Form/Activity.php | 4 +-- CRM/Report/Form/ActivitySummary.php | 2 +- CRM/Report/Form/Campaign/SurveyDetails.php | 2 +- CRM/Report/Form/Contact/Detail.php | 2 +- CRM/Report/Form/Contact/Log.php | 2 +- CRM/Upgrade/Incremental/php/FourFour.php | 2 +- CRM/Utils/Migrate/ExportJSON.php | 2 +- sql/GenerateData.php | 6 ++-- sql/GenerateReportData.php | 2 +- tests/phpunit/api/v3/ActionScheduleTest.php | 4 +-- 38 files changed, 71 insertions(+), 71 deletions(-) diff --git a/CRM/Activity/ActionMapping.php b/CRM/Activity/ActionMapping.php index 26e994b82280..b80bc8996c65 100644 --- a/CRM/Activity/ActionMapping.php +++ b/CRM/Activity/ActionMapping.php @@ -108,7 +108,7 @@ public function createQuery($schedule, $phase, $defaultParams) { $query['casDateField'] = 'e.activity_date_time'; if (!is_null($schedule->limit_to)) { - $activityContacts = \CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = \CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); if ($schedule->limit_to == 0 || !isset($activityContacts[$schedule->recipient])) { $recipientTypeId = \CRM_Utils_Array::key('Activity Targets', $activityContacts); } diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index a4b2d9faeac5..a33161712daa 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -92,7 +92,7 @@ public static function retrieve(&$params, &$defaults) { $activity->copyValues($params); if ($activity->find(TRUE)) { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); @@ -209,7 +209,7 @@ public static function deleteActivity(&$params, $moveToTrash = FALSE) { $logMsg = 'Case Activity deleted for'; $msgs = array(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -633,7 +633,7 @@ public static function create(&$params) { public static function logActivityAction($activity, $logMessage = NULL) { $id = CRM_Core_Session::getLoggedInContactID(); if (!$id) { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $id = self::getActivityContact($activity->id, $sourceID); } @@ -672,7 +672,7 @@ public static function getActivities($params, $getCount = FALSE) { $activities = array(); // fetch all active activity types - $activityTypes = CRM_Core_OptionGroup::values('activity_type'); + $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'get'); // Activity.Get API params $activityParams = array( @@ -886,7 +886,7 @@ public static function deprecatedGetActivities($input) { 'Bulk Email' ); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -1307,7 +1307,7 @@ public static function deprecatedGetActivitySQLClause($input) { // build main activity table select clause $sourceSelect = ''; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $sourceJoin = " INNER JOIN civicrm_activity_contact ac ON ac.activity_id = civicrm_activity.id @@ -1824,7 +1824,7 @@ public static function sendSMSMessage( return $sendResult; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); // add activity target record for every sms that is send @@ -1888,7 +1888,7 @@ public static function sendMessage( $toDisplayName = $toEmail; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); // create the params array @@ -1990,7 +1990,7 @@ public static function &importableFields($status = FALSE) { public static function getContactActivity($contactId) { // @todo remove this function entirely. $activities = array(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -2030,8 +2030,8 @@ public static function getContactActivity($contactId) { $dao = CRM_Core_DAO::executeQuery($query); - $activityTypes = CRM_Core_OptionGroup::values('activity_type'); - $activityStatuses = CRM_Core_OptionGroup::values('activity_status'); + $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'get'); + $activityStatuses = CRM_Activity_BAO_Activity::buildOptions('activity_status_id', 'get'); while ($dao->fetch()) { $activities[$dao->activity_id]['id'] = $dao->activity_id; @@ -2610,7 +2610,7 @@ public static function cleanupActivity($contactId) { if (!$contactId) { return $result; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $transaction = new CRM_Core_Transaction(); @@ -2745,7 +2745,7 @@ public static function checkPermission($activityId, $action) { $permission = CRM_Core_Permission::EDIT; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -3083,7 +3083,7 @@ public static function getActivityContact($activityId, $recordTypeID = NULL, $co public static function getSourceContactID($activityId) { static $sourceID = NULL; if (!$sourceID) { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); } @@ -3100,7 +3100,7 @@ public static function getSourceContactID($activityId) { public function setApiFilter(&$params) { if (!empty($params['target_contact_id'])) { $this->selectAdd(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $obj = new CRM_Activity_BAO_ActivityContact(); $params['return.target_contact_id'] = 1; diff --git a/CRM/Activity/BAO/ActivityAssignment.php b/CRM/Activity/BAO/ActivityAssignment.php index 5e4a46b8d2b9..3f19f83cac1f 100644 --- a/CRM/Activity/BAO/ActivityAssignment.php +++ b/CRM/Activity/BAO/ActivityAssignment.php @@ -54,7 +54,7 @@ public function __construct() { */ public static function create(&$params) { $assignment = new CRM_Activity_BAO_ActivityContact(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $assignment->copyValues($params); @@ -76,7 +76,7 @@ public static function retrieveAssigneeIdsByActivityId($activity_id) { return $assigneeArray; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $sql = " @@ -112,7 +112,7 @@ public static function getAssigneeNames($activityIDs, $isDisplayName = FALSE, $s if (empty($activityIDs)) { return $assigneeNames; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $whereClause = ""; diff --git a/CRM/Activity/BAO/ActivityTarget.php b/CRM/Activity/BAO/ActivityTarget.php index 76acae7f344f..2c548156ac49 100644 --- a/CRM/Activity/BAO/ActivityTarget.php +++ b/CRM/Activity/BAO/ActivityTarget.php @@ -53,7 +53,7 @@ public function __construct() { */ public static function create(&$params) { $target = new CRM_Activity_BAO_ActivityContact(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $target->copyValues($params); @@ -74,7 +74,7 @@ public static function retrieveTargetIdsByActivityId($activity_id) { return $targetArray; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $sql = " @@ -105,7 +105,7 @@ public static function getTargetNames($activityID) { if (empty($activityID)) { return $targetNames; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $query = " diff --git a/CRM/Activity/BAO/Query.php b/CRM/Activity/BAO/Query.php index 50fd655799dc..2287312afa1f 100644 --- a/CRM/Activity/BAO/Query.php +++ b/CRM/Activity/BAO/Query.php @@ -247,7 +247,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'activity_role': CRM_Contact_BAO_Query::$_activityRole = $values[2]; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -399,7 +399,7 @@ public static function from($name, $mode, $side) { break; case 'source_contact': - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $from = " LEFT JOIN civicrm_activity_contact ac diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 071e3c1bad94..7187c523d3a9 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -986,7 +986,7 @@ public function postProcess($params = NULL) { */ protected function processActivity(&$params) { $activityAssigned = array(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); // format assignee params if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) { diff --git a/CRM/Activity/Form/Task.php b/CRM/Activity/Form/Task.php index 9bc63a052e41..90131945fde6 100644 --- a/CRM/Activity/Form/Task.php +++ b/CRM/Activity/Form/Task.php @@ -164,7 +164,7 @@ public static function preProcessCommon(&$form, $useTable = FALSE) { public function setContactIDs() { $IDs = implode(',', $this->_activityHolderIds); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $query = " SELECT contact_id diff --git a/CRM/Activity/Form/Task/PickOption.php b/CRM/Activity/Form/Task/PickOption.php index 12cc7e4479d4..7914eb9eb6fd 100644 --- a/CRM/Activity/Form/Task/PickOption.php +++ b/CRM/Activity/Form/Task/PickOption.php @@ -131,7 +131,7 @@ public function postProcess() { $params = $this->exportValues(); $this->_contacts = array(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); // Get assignee contacts. diff --git a/CRM/Activity/Form/Task/SearchTaskHookSample.php b/CRM/Activity/Form/Task/SearchTaskHookSample.php index 9a403edf4c58..a9251f0280d6 100644 --- a/CRM/Activity/Form/Task/SearchTaskHookSample.php +++ b/CRM/Activity/Form/Task/SearchTaskHookSample.php @@ -46,7 +46,7 @@ public function preProcess() { // display name and activity details of all selected contacts $activityIDs = implode(',', $this->_activityHolderIds); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $query = " SELECT at.subject as subject, diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index a7fab121825e..797aaed93bb8 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -339,7 +339,7 @@ public static function _convertToCaseActivity($params) { $targetContacts = array_unique(explode(',', $params['targetContactIds'])); } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); diff --git a/CRM/Activity/Selector/Search.php b/CRM/Activity/Selector/Search.php index 4e79ea20934a..8252b500426f 100644 --- a/CRM/Activity/Selector/Search.php +++ b/CRM/Activity/Selector/Search.php @@ -269,7 +269,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); $engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); diff --git a/CRM/Campaign/BAO/Petition.php b/CRM/Campaign/BAO/Petition.php index 2f85010a56ec..cb1c1b72a618 100644 --- a/CRM/Campaign/BAO/Petition.php +++ b/CRM/Campaign/BAO/Petition.php @@ -240,7 +240,7 @@ public function confirmSignature($activity_id, $contact_id, $petition_id) { // change activity status to completed (status_id = 2) // I wonder why do we need contact_id when we have activity_id anyway? [chastell] $sql = 'UPDATE civicrm_activity SET status_id = 2 WHERE id = %1'; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $params = array( 1 => array($activity_id, 'Integer'), @@ -307,7 +307,7 @@ public static function getPetitionSignatureTotalbyCountry($surveyId) { civicrm_survey.id = %1 AND a.source_record_id = %1 "; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $params = array( 1 => array($surveyId, 'Integer'), @@ -432,7 +432,7 @@ public static function getPetitionSignature($surveyId, $status_id = NULL) { } $sql .= " ORDER BY a.activity_date_time"; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $params[3] = array($sourceID, 'Integer'); @@ -497,7 +497,7 @@ public static function checkSignature($surveyId, $contactId) { $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo($surveyId); $signature = array(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $sql = " diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php index 6ccf34faf7c4..1a181247d07b 100644 --- a/CRM/Campaign/BAO/Query.php +++ b/CRM/Campaign/BAO/Query.php @@ -221,7 +221,7 @@ public static function from($name, $mode, $side) { return $from; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); diff --git a/CRM/Campaign/BAO/Survey.php b/CRM/Campaign/BAO/Survey.php index dfc855e62108..a652633d726a 100644 --- a/CRM/Campaign/BAO/Survey.php +++ b/CRM/Campaign/BAO/Survey.php @@ -529,7 +529,7 @@ public static function voterActivityDetails($surveyId, $voterIds, $interviewerId } $targetContactIds = ' ( ' . implode(',', $voterIds) . ' ) '; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -625,7 +625,7 @@ public static function getSurveyActivities( contact_a.display_name as voter_name"; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -1046,7 +1046,7 @@ public static function getInterviewers() { } $interviewers = array(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $query = " diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index df23c5fa1cda..0d5e6fd2490d 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -862,7 +862,7 @@ public static function getCaseRoles($contactID, $caseID, $relationshipID = NULL) public static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL) { $values = array(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -2086,7 +2086,7 @@ public static function mergeCases( $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'); $activityStatuses = CRM_Core_PseudoConstant::activityStatus('name'); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -2624,7 +2624,7 @@ public static function checkPermission($activityId, $operation, $actTypeId = NUL //edit - contact must be source or assignee //view - contact must be source/assignee/target $isTarget = $isAssignee = $isSource = FALSE; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); diff --git a/CRM/Case/BAO/Query.php b/CRM/Case/BAO/Query.php index 92358ef52144..2776a6e1d40a 100644 --- a/CRM/Case/BAO/Query.php +++ b/CRM/Case/BAO/Query.php @@ -517,7 +517,7 @@ public static function from($name, $mode, $side) { break; case 'civicrm_case_reporter': - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $from .= " $side JOIN civicrm_activity_contact as case_activity_contact ON (case_activity.id = case_activity_contact.activity_id AND case_activity_contact.record_type_id = {$sourceID} ) "; $from .= " $side JOIN civicrm_contact as civicrm_case_reporter ON case_activity_contact.contact_id = civicrm_case_reporter.id "; diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index 338cd364572d..9e913a492688 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -589,7 +589,7 @@ public function postProcess($params = NULL) { //CRM-5695 //check for notification settings for assignee contacts $selectedContacts = array('contact_check'); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); if (Civi::settings()->get('activity_assignee_notification')) { $selectedContacts[] = 'assignee_contact_id'; diff --git a/CRM/Case/Form/ActivityView.php b/CRM/Case/Form/ActivityView.php index a772ef6ead47..7b1ccd7b7a29 100644 --- a/CRM/Case/Form/ActivityView.php +++ b/CRM/Case/Form/ActivityView.php @@ -123,7 +123,7 @@ public function preProcess() { //viewing activity should get diplayed in recent list.CRM-4670 $activityTypeID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'activity_type_id'); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $activityTargetContacts = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($activityID, $targetID); if (!empty($activityTargetContacts)) { diff --git a/CRM/Case/XMLProcessor/Process.php b/CRM/Case/XMLProcessor/Process.php index 6ba3a4a3bed0..1caf260cb46a 100644 --- a/CRM/Case/XMLProcessor/Process.php +++ b/CRM/Case/XMLProcessor/Process.php @@ -361,7 +361,7 @@ public function getDeclaredRelationshipTypes($caseTypeXML) { * @param array $params */ public function deleteEmptyActivity(&$params) { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $query = " diff --git a/CRM/Case/XMLProcessor/Report.php b/CRM/Case/XMLProcessor/Report.php index 0a900c54b81d..8ece8d55998d 100644 --- a/CRM/Case/XMLProcessor/Report.php +++ b/CRM/Case/XMLProcessor/Report.php @@ -267,7 +267,7 @@ public function &getActivityInfo($clientID, $activityID, $anyActivity = FALSE, $ $joinCaseActivity = " INNER JOIN civicrm_case_activity ca ON a.id = ca.activity_id "; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); @@ -353,7 +353,7 @@ public function &getActivity($clientID, $activityDAO, &$activityTypeInfo) { ); } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); if (!empty($activityDAO->targetID)) { @@ -425,7 +425,7 @@ public function &getActivity($clientID, $activityDAO, &$activityTypeInfo) { 'value' => $this->redact($creator), 'type' => 'String', ); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $source_contact_id = CRM_Activity_BAO_Activity::getActivityContact($activityDAO->id, $sourceID); $reporter = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index 9cbb44d53b0c..024ef8504203 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -702,7 +702,7 @@ public static function contactDetails($componentIds, $componentName, $returnProp } elseif ($componentName == 'Activity') { $compTable = 'civicrm_activity'; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); } else { $compTable = 'civicrm_participant'; diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index eb58c2ecc022..4663310e1023 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -3168,7 +3168,7 @@ public function tagSearch(&$values) { // search tag in activities $etActTable = "`civicrm_entity_act_tag-" . $value . "`"; $tActTable = "`civicrm_act_tag-" . $value . "`"; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $this->_tables[$etActTable] = $this->_whereTables[$etActTable] @@ -3227,7 +3227,7 @@ public function tag(&$values) { // search tag in cases $etCaseTable = "`civicrm_entity_case_tag-" . $value . "`"; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $this->_tables[$etCaseTable] = $this->_whereTables[$etCaseTable] diff --git a/CRM/Contact/Form/Search/Custom/ActivitySearch.php b/CRM/Contact/Form/Search/Custom/ActivitySearch.php index 72bd86e2582c..066da42b7aab 100644 --- a/CRM/Contact/Form/Search/Custom/ActivitySearch.php +++ b/CRM/Contact/Form/Search/Custom/ActivitySearch.php @@ -259,7 +259,7 @@ public function alterRow(&$row) { */ public function from() { $this->buildACLClause('contact_a'); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); diff --git a/CRM/Contact/Form/Task/SMSCommon.php b/CRM/Contact/Form/Task/SMSCommon.php index a4ab022d269c..9c36efbfb646 100644 --- a/CRM/Contact/Form/Task/SMSCommon.php +++ b/CRM/Contact/Form/Task/SMSCommon.php @@ -140,7 +140,7 @@ public static function buildQuickForm(&$form) { continue; } - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); //target contacts limit check $ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID)); diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 1f4f89c02fd8..374296ed5890 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2276,7 +2276,7 @@ public static function getOnbehalfIds($contributionId, $contributorId = NULL) { AND civicrm_activity_contact.record_type_id = %3 "; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $params = array( diff --git a/CRM/Friend/BAO/Friend.php b/CRM/Friend/BAO/Friend.php index acd6ca2a48c9..b79126f6ace9 100644 --- a/CRM/Friend/BAO/Friend.php +++ b/CRM/Friend/BAO/Friend.php @@ -134,7 +134,7 @@ public static function create(&$params) { //activity creation $activity = CRM_Activity_BAO_Activity::create($activityParams); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); //friend contacts creation diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 32deba6f856e..ccb550271252 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -106,7 +106,7 @@ public function diffsInTable($table, $contactID = NULL) { break; case 'civicrm_activity': - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); diff --git a/CRM/Mailing/BAO/MailingJob.php b/CRM/Mailing/BAO/MailingJob.php index 8f1469242f65..01251872e584 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -962,7 +962,7 @@ public function writeToDB( if (CRM_Core_BAO_Email::isMultipleBulkMail()) { static $targetRecordID = NULL; if (!$targetRecordID) { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $targetRecordID = CRM_Utils_Array::key('Activity Targets', $activityContacts); } diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index 3923c6d996ac..2a0a6798c18f 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -492,7 +492,7 @@ public function select($recordType = NULL) { * @param string $recordType */ public function from($recordType) { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $activityTypeId = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_OptionGroup", 'activity_type', 'id', 'name'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -779,7 +779,7 @@ public function postProcess() { $this->_formValues["activity_date_time_relative"] = NULL; } $this->beginPostProcess(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); //Assign those recordtype to array which have filter operator as 'Is not empty' or 'Is empty' diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index c8978ec05c02..44e223b7fb46 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -301,7 +301,7 @@ public function select() { * @param bool|FALSE $durationMode */ public function from($durationMode = FALSE) { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); diff --git a/CRM/Report/Form/Campaign/SurveyDetails.php b/CRM/Report/Form/Campaign/SurveyDetails.php index d5c7b58e69f2..ad6e51ae5419 100644 --- a/CRM/Report/Form/Campaign/SurveyDetails.php +++ b/CRM/Report/Form/Campaign/SurveyDetails.php @@ -262,7 +262,7 @@ public function select() { public function from() { $this->_from = " FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom} "; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); diff --git a/CRM/Report/Form/Contact/Detail.php b/CRM/Report/Form/Contact/Detail.php index 45f0e4d6f0b7..c715aea841c1 100644 --- a/CRM/Report/Form/Contact/Detail.php +++ b/CRM/Report/Form/Contact/Detail.php @@ -514,7 +514,7 @@ public function from() { } if (!empty($this->_selectComponent['activity_civireport'])) { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); diff --git a/CRM/Report/Form/Contact/Log.php b/CRM/Report/Form/Contact/Log.php index e52628a5f085..3c1279207fca 100644 --- a/CRM/Report/Form/Contact/Log.php +++ b/CRM/Report/Form/Contact/Log.php @@ -175,7 +175,7 @@ public static function formRule($fields, $files, $self) { } public function from() { - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $this->_from = " FROM civicrm_log {$this->_aliases['civicrm_log']} diff --git a/CRM/Upgrade/Incremental/php/FourFour.php b/CRM/Upgrade/Incremental/php/FourFour.php index 4fa535496471..baea3d8c8688 100644 --- a/CRM/Upgrade/Incremental/php/FourFour.php +++ b/CRM/Upgrade/Incremental/php/FourFour.php @@ -543,7 +543,7 @@ public static function setContactImageUrl($cid, $newImageUrl) { public static function activityContacts(CRM_Queue_TaskContext $ctx) { $upgrade = new CRM_Upgrade_Form(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $ovValue[] = $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $ovValue[] = $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $ovValue[] = $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); diff --git a/CRM/Utils/Migrate/ExportJSON.php b/CRM/Utils/Migrate/ExportJSON.php index b97e47ab1497..9b90e98ba1a2 100644 --- a/CRM/Utils/Migrate/ExportJSON.php +++ b/CRM/Utils/Migrate/ExportJSON.php @@ -449,7 +449,7 @@ public function relationship(&$contactIDs, &$additionalContacts) { */ public function activity(&$contactIDs, &$additionalContacts) { static $_activitiesHandled = array(); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $ids = implode(',', $contactIDs); diff --git a/sql/GenerateData.php b/sql/GenerateData.php index 7f6d0c7e1899..f837c0a70f46 100644 --- a/sql/GenerateData.php +++ b/sql/GenerateData.php @@ -1199,7 +1199,7 @@ private function addActivity() { $contactDAO->find(); $count = 0; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); while ($contactDAO->fetch()) { if ($count++ > 2) { break; @@ -1318,7 +1318,7 @@ private function addMembershipType() { private function addMembership() { $contact = new CRM_Contact_DAO_Contact(); $contact->query("SELECT id FROM civicrm_contact where contact_type = 'Individual'"); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); while ($contact->fetch()) { $contacts[] = $contact->id; } @@ -1693,7 +1693,7 @@ private function addParticipant() { (contact_id, activity_id, record_type_id) VALUES "; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $currentActivityID = CRM_Core_DAO::singleValueQuery("SELECT MAX(id) FROM civicrm_activity"); $currentActivityID -= 50; $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); diff --git a/sql/GenerateReportData.php b/sql/GenerateReportData.php index f5eafbc276d8..6119aff6bf28 100644 --- a/sql/GenerateReportData.php +++ b/sql/GenerateReportData.php @@ -1188,7 +1188,7 @@ public function addActivity() { $contactDAO->find(); $count = 0; - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); while ($contactDAO->fetch()) { if ($count++ > 2) { diff --git a/tests/phpunit/api/v3/ActionScheduleTest.php b/tests/phpunit/api/v3/ActionScheduleTest.php index c455aa971ebf..405630d37d45 100644 --- a/tests/phpunit/api/v3/ActionScheduleTest.php +++ b/tests/phpunit/api/v3/ActionScheduleTest.php @@ -50,7 +50,7 @@ public function setUp() { */ public function testSimpleActionScheduleCreate() { $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $title = "simpleActionSchedule" . substr(sha1(rand()), 0, 7); $params = array( @@ -87,7 +87,7 @@ public function testActionScheduleCreateWithoutRequired() { */ public function testActionScheduleWithScheduledDatesCreate() { $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); - $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); + $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $title = "simpleActionSchedule" . substr(sha1(rand()), 0, 7); $params = array( From f9aa1e86f32decd0713d7ad433981abd768f6012 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 28 Aug 2017 18:19:06 +0100 Subject: [PATCH 2/2] Update based on comments from @eileenmcnaughton --- CRM/Activity/BAO/Activity.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index a33161712daa..2f4386695d1b 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -672,7 +672,7 @@ public static function getActivities($params, $getCount = FALSE) { $activities = array(); // fetch all active activity types - $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'get'); + $activityTypes = CRM_Core_OptionGroup::values('activity_type'); // Activity.Get API params $activityParams = array( @@ -2030,9 +2030,6 @@ public static function getContactActivity($contactId) { $dao = CRM_Core_DAO::executeQuery($query); - $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'get'); - $activityStatuses = CRM_Activity_BAO_Activity::buildOptions('activity_status_id', 'get'); - while ($dao->fetch()) { $activities[$dao->activity_id]['id'] = $dao->activity_id; $activities[$dao->activity_id]['activity_type_id'] = $dao->activity_type_id; @@ -2041,8 +2038,8 @@ public static function getContactActivity($contactId) { $activities[$dao->activity_id]['activity_date_time'] = $dao->activity_date_time; $activities[$dao->activity_id]['details'] = $dao->details; $activities[$dao->activity_id]['status_id'] = $dao->status_id; - $activities[$dao->activity_id]['activity_name'] = $activityTypes[$dao->activity_type_id]; - $activities[$dao->activity_id]['status'] = $activityStatuses[$dao->status_id]; + $activities[$dao->activity_id]['activity_name'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $dao->activity_type_id); + $activities[$dao->activity_id]['status'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_status_id', $dao->status_id); // set to null if not set if (!isset($activities[$dao->activity_id]['source_contact_id'])) {