3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
35 * This class generates form components for Activity Links.
37 class CRM_Activity_Form_ActivityLinks
extends CRM_Core_Form
{
39 public function buildQuickForm() {
40 self
::commonBuildQuickForm($this);
46 public static function commonBuildQuickForm($self) {
47 $contactId = CRM_Utils_Request
::retrieve('cid', 'Positive', $self);
49 $contactId = CRM_Utils_Request
::retrieve('cid', 'Positive', CRM_Core_DAO
::$_nullObject, FALSE, NULL, $_REQUEST);
51 $urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype=";
53 $allTypes = CRM_Utils_Array
::value('values', civicrm_api3('OptionValue', 'get', [
54 'option_group_id' => 'activity_type',
56 'options' => ['limit' => 0, 'sort' => 'weight'],
61 foreach ($allTypes as $act) {
62 $url = 'civicrm/activity/add';
63 if ($act['name'] == 'Email') {
64 if (!CRM_Utils_Mail
::validOutBoundMail() ||
!$contactId) {
67 list($name, $email, $doNotEmail, $onHold, $isDeceased) = CRM_Contact_BAO_Contact
::getContactDetails($contactId);
68 if (!$doNotEmail && $email && !$isDeceased) {
69 $url = 'civicrm/activity/email/add';
70 $act['label'] = ts('Send an Email');
76 elseif ($act['name'] == 'SMS') {
77 if (!$contactId ||
!CRM_SMS_BAO_Provider
::activeProviderCount() ||
!CRM_Core_Permission
::check('send SMS')) {
80 // Check for existence of a mobile phone and ! do not SMS privacy setting
82 $phone = civicrm_api3('Phone', 'getsingle', [
83 'contact_id' => $contactId,
84 'phone_type_id' => CRM_Core_PseudoConstant
::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile'),
85 'return' => ['phone', 'contact_id'],
86 'options' => ['limit' => 1, 'sort' => "is_primary DESC"],
87 'api.Contact.getsingle' => [
88 'id' => '$value.contact_id',
89 'return' => 'do_not_sms',
93 catch (CiviCRM_API3_Exception
$e) {
96 if (!$phone['api.Contact.getsingle']['do_not_sms'] && $phone['phone']) {
97 $url = 'civicrm/activity/sms/add';
103 elseif ($act['name'] == 'Print PDF Letter') {
104 $url = 'civicrm/activity/pdf/add';
106 elseif (!empty($act['filter']) ||
(!empty($act['component_id']) && $act['component_id'] != '1')) {
109 $act['url'] = CRM_Utils_System
::url($url,
110 "{$urlParams}{$act['value']}", FALSE, NULL, FALSE
112 $act +
= ['icon' => 'fa-plus-square-o'];
113 $activityTypes[$act['value']] = $act;
116 $self->assign('activityTypes', $activityTypes);
118 $self->assign('suppressForm', TRUE);