'activity_type', 'is_active' => 1, 'options' => ['limit' => 0, 'sort' => 'weight'], ])); $activityTypes = []; foreach ($allTypes as $act) { $url = 'civicrm/activity/add'; if ($act['name'] == 'Email') { if (!CRM_Utils_Mail::validOutBoundMail() || !$contactId) { continue; } list($name, $email, $doNotEmail, $onHold, $isDeceased) = CRM_Contact_BAO_Contact::getContactDetails($contactId); if (!$doNotEmail && $email && !$isDeceased) { $url = 'civicrm/activity/email/add'; $act['label'] = ts('Send an Email'); } else { continue; } } elseif ($act['name'] == 'SMS') { if (!$contactId || !CRM_SMS_BAO_Provider::activeProviderCount() || !CRM_Core_Permission::check('send SMS')) { continue; } // Check for existence of a mobile phone and ! do not SMS privacy setting try { $phone = civicrm_api3('Phone', 'getsingle', [ 'contact_id' => $contactId, 'phone_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile'), 'return' => ['phone', 'contact_id'], 'options' => ['limit' => 1, 'sort' => "is_primary DESC"], 'api.Contact.getsingle' => [ 'id' => '$value.contact_id', 'return' => 'do_not_sms', ], ]); } catch (CiviCRM_API3_Exception $e) { continue; } if (!$phone['api.Contact.getsingle']['do_not_sms'] && $phone['phone']) { $url = 'civicrm/activity/sms/add'; } else { continue; } } elseif ($act['name'] == 'Print PDF Letter') { $url = 'civicrm/activity/pdf/add'; } elseif (!empty($act['filter']) || (!empty($act['component_id']) && $act['component_id'] != '1')) { continue; } $act['url'] = CRM_Utils_System::url($url, "{$urlParams}{$act['value']}", FALSE, NULL, FALSE ); $act += ['icon' => 'fa-plus-square-o']; $activityTypes[$act['value']] = $act; } $self->assign('activityTypes', $activityTypes); $self->assign('suppressForm', TRUE); } }