Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21023 Replace deprecated code and hardcoded IDs with pseudoconstants in Activity BAO #10816

Merged
merged 1 commit into from
Aug 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ public static function create(&$params) {
if (isset($params['activity_date_time']) &&
strcmp($params['activity_date_time'], CRM_Utils_Date::processDate(date('Ymd')) == -1)
) {
$params['status_id'] = 2;
$params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Completed');
}
else {
$params['status_id'] = 1;
$params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled');
}
}

Expand Down Expand Up @@ -352,10 +352,9 @@ public static function create(&$params) {
}

$activityId = $activity->id;
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$sourceID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Source');
$assigneeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Assignees');
$targetID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Targets');

if (isset($params['source_contact_id'])) {
$acParams = array(
Expand Down Expand Up @@ -567,7 +566,7 @@ public static function create(&$params) {
if (!isset($activity->parent_id)) {
$recentContactDisplay = CRM_Contact_BAO_Contact::displayName($recentContactId);
// add the recently created Activity
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
$activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id');
$activitySubject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activity->id, 'subject');

$title = "";
Expand Down Expand Up @@ -1679,8 +1678,7 @@ public static function sendSMS(
'activity_date_time' => date('YmdHis'),
'subject' => $activitySubject,
'details' => $details,
// FIXME: check for name Completed and get ID from that lookup
'status_id' => 2,
'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Completed'),
);

$activity = self::create($activityParams);
Expand Down Expand Up @@ -1727,8 +1725,7 @@ public static function sendSMS(
$tokenText = CRM_Utils_Token::replaceHookTokens($tokenText, $values, $categories, FALSE, $escapeSmarty);

// Only send if the phone is of type mobile
$phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name');
if ($values['phone_type_id'] == CRM_Utils_Array::value('Mobile', $phoneTypes)) {
if ($values['phone_type_id'] == CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile')) {
$smsParams['To'] = $values['phone'];
}
else {
Expand Down