Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
e7112fa7 | 31 | * @copyright CiviCRM LLC (c) 2004-2015 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This class generates form components for Activity Links | |
38 | * | |
39 | */ | |
40 | class CRM_Activity_Form_ActivityLinks extends CRM_Core_Form { | |
41 | public function buildQuickForm() { | |
cfcb7676 DL |
42 | self::commonBuildQuickForm($this); |
43 | } | |
44 | ||
ffd93213 EM |
45 | /** |
46 | * @param $self | |
47 | */ | |
00be9182 | 48 | public static function commonBuildQuickForm($self) { |
cfcb7676 | 49 | $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $self); |
6a488035 TO |
50 | if (!$contactId) { |
51 | $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST); | |
52 | } | |
53 | $urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype="; | |
54 | ||
55 | $activityTypes = $urls = array(); | |
56 | ||
57 | $emailTypeId = CRM_Core_OptionGroup::getValue('activity_type', | |
58 | 'Email', | |
59 | 'name' | |
60 | ); | |
61 | ||
62 | $letterTypeId = CRM_Core_OptionGroup::getValue('activity_type', | |
63 | 'Print PDF Letter', | |
64 | 'name' | |
65 | ); | |
66 | $SMSId = CRM_Core_OptionGroup::getValue('activity_type', | |
67 | 'Text Message (SMS)', | |
68 | 'label' | |
69 | ); | |
cfcb7676 | 70 | |
6a488035 TO |
71 | if (CRM_Utils_Mail::validOutBoundMail() && $contactId) { |
72 | list($name, $email, $doNotEmail, $onHold, $isDeseased) = CRM_Contact_BAO_Contact::getContactDetails($contactId); | |
73 | if (!$doNotEmail && $email && !$isDeseased) { | |
74 | $activityTypes = array($emailTypeId => ts('Send an Email')); | |
75 | } | |
76 | } | |
77 | ||
78 | if ($contactId && CRM_SMS_BAO_Provider::activeProviderCount()) { | |
79 | // Check for existence of a mobile phone and ! do not SMS privacy setting | |
80 | $mobileTypeID = CRM_Core_OptionGroup::getValue('phone_type', 'Mobile', 'name'); | |
81 | list($name, $phone, $doNotSMS) = CRM_Contact_BAO_Contact_Location::getPhoneDetails($contactId, $mobileTypeID); | |
cfcb7676 | 82 | |
6a488035 | 83 | if (!$doNotSMS && $phone) { |
32864ccf | 84 | $sendSMS = array($SMSId => ts('Send SMS')); |
6a488035 TO |
85 | $activityTypes += $sendSMS; |
86 | } | |
87 | } | |
88 | // this returns activity types sorted by weight | |
89 | $otherTypes = CRM_Core_PseudoConstant::activityType(FALSE); | |
90 | ||
91 | $activityTypes += $otherTypes; | |
92 | ||
93 | foreach (array_keys($activityTypes) as $typeId) { | |
94 | if ($typeId == $emailTypeId) { | |
95 | $urls[$typeId] = CRM_Utils_System::url('civicrm/activity/email/add', | |
96 | "{$urlParams}{$typeId}", FALSE, NULL, FALSE | |
97 | ); | |
98 | } | |
32864ccf | 99 | elseif ($typeId == $SMSId) { |
6a488035 TO |
100 | $urls[$typeId] = CRM_Utils_System::url('civicrm/activity/sms/add', |
101 | "{$urlParams}{$typeId}", FALSE, NULL, FALSE | |
102 | ); | |
32864ccf | 103 | } |
6a488035 TO |
104 | elseif ($typeId == $letterTypeId) { |
105 | $urls[$typeId] = CRM_Utils_System::url('civicrm/activity/pdf/add', | |
106 | "{$urlParams}{$typeId}", FALSE, NULL, FALSE | |
107 | ); | |
108 | } | |
109 | else { | |
110 | $urls[$typeId] = CRM_Utils_System::url('civicrm/activity/add', | |
111 | "{$urlParams}{$typeId}", FALSE, NULL, FALSE | |
112 | ); | |
113 | } | |
114 | } | |
115 | ||
cfcb7676 DL |
116 | $self->assign('activityTypes', $activityTypes); |
117 | $self->assign('urls', $urls); | |
6a488035 | 118 | |
cfcb7676 | 119 | $self->assign('suppressForm', TRUE); |
6a488035 | 120 | } |
96025800 | 121 | |
6a488035 | 122 | } |