3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
35 * This class generates form components for Activity Links.
37 class CRM_Activity_Form_ActivityLinks
extends CRM_Core_Form
{
38 public function buildQuickForm() {
39 self
::commonBuildQuickForm($this);
45 public static function commonBuildQuickForm($self) {
46 $contactId = CRM_Utils_Request
::retrieve('cid', 'Positive', $self);
48 $contactId = CRM_Utils_Request
::retrieve('cid', 'Positive', CRM_Core_DAO
::$_nullObject, FALSE, NULL, $_REQUEST);
50 $urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype=";
52 $activityTypes = $urls = array();
54 $emailTypeId = CRM_Core_OptionGroup
::getValue('activity_type',
59 $letterTypeId = CRM_Core_OptionGroup
::getValue('activity_type',
63 $SMSId = CRM_Core_OptionGroup
::getValue('activity_type',
68 if (CRM_Utils_Mail
::validOutBoundMail() && $contactId) {
69 list($name, $email, $doNotEmail, $onHold, $isDeseased) = CRM_Contact_BAO_Contact
::getContactDetails($contactId);
70 if (!$doNotEmail && $email && !$isDeseased) {
71 $activityTypes = array($emailTypeId => ts('Send an Email'));
75 if ($contactId && CRM_SMS_BAO_Provider
::activeProviderCount()) {
76 // Check for existence of a mobile phone and ! do not SMS privacy setting
77 $mobileTypeID = CRM_Core_OptionGroup
::getValue('phone_type', 'Mobile', 'name');
78 list($name, $phone, $doNotSMS) = CRM_Contact_BAO_Contact_Location
::getPhoneDetails($contactId, $mobileTypeID);
80 if (!$doNotSMS && $phone) {
81 $sendSMS = array($SMSId => ts('Send SMS'));
82 $activityTypes +
= $sendSMS;
85 // this returns activity types sorted by weight
86 $otherTypes = CRM_Core_PseudoConstant
::activityType(FALSE);
88 $activityTypes +
= $otherTypes;
90 foreach (array_keys($activityTypes) as $typeId) {
91 if ($typeId == $emailTypeId) {
92 $urls[$typeId] = CRM_Utils_System
::url('civicrm/activity/email/add',
93 "{$urlParams}{$typeId}", FALSE, NULL, FALSE
96 elseif ($typeId == $SMSId) {
97 $urls[$typeId] = CRM_Utils_System
::url('civicrm/activity/sms/add',
98 "{$urlParams}{$typeId}", FALSE, NULL, FALSE
101 elseif ($typeId == $letterTypeId) {
102 $urls[$typeId] = CRM_Utils_System
::url('civicrm/activity/pdf/add',
103 "{$urlParams}{$typeId}", FALSE, NULL, FALSE
107 $urls[$typeId] = CRM_Utils_System
::url('civicrm/activity/add',
108 "{$urlParams}{$typeId}", FALSE, NULL, FALSE
113 $self->assign('activityTypes', $activityTypes);
114 $self->assign('urls', $urls);
116 $self->assign('suppressForm', TRUE);