'activity_type', 'is_active' => 1, 'options' => array('limit' => 0, 'sort' => 'weight'), ))); $activityTypes = array(); 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()) { continue; } // Check for existence of a mobile phone and ! do not SMS privacy setting $mobileTypeID = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile'); list($name, $phone, $doNotSMS) = CRM_Contact_BAO_Contact_Location::getPhoneDetails($contactId, $mobileTypeID); if (!$doNotSMS && $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 += array('icon' => 'fa-plus-square-o'); $activityTypes[$act['value']] = $act; } $self->assign('activityTypes', $activityTypes); $self->assign('suppressForm', TRUE); } }