3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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-2018
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 $allTypes = CRM_Utils_Array
::value('values', civicrm_api3('OptionValue', 'get', array(
53 'option_group_id' => 'activity_type',
55 'options' => array('limit' => 0, 'sort' => 'weight'),
58 $activityTypes = array();
60 foreach ($allTypes as $act) {
61 $url = 'civicrm/activity/add';
62 if ($act['name'] == 'Email') {
63 if (!CRM_Utils_Mail
::validOutBoundMail() ||
!$contactId) {
66 list($name, $email, $doNotEmail, $onHold, $isDeceased) = CRM_Contact_BAO_Contact
::getContactDetails($contactId);
67 if (!$doNotEmail && $email && !$isDeceased) {
68 $url = 'civicrm/activity/email/add';
69 $act['label'] = ts('Send an Email');
75 elseif ($act['name'] == 'SMS') {
76 if (!$contactId ||
!CRM_SMS_BAO_Provider
::activeProviderCount() ||
!CRM_Core_Permission
::check('send SMS')) {
79 // Check for existence of a mobile phone and ! do not SMS privacy setting
81 $phone = civicrm_api3('Phone', 'getsingle', array(
82 'contact_id' => $contactId,
83 'phone_type_id' => CRM_Core_PseudoConstant
::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile'),
84 'return' => array('phone', 'contact_id'),
85 'options' => array('limit' => 1, 'sort' => "is_primary DESC"),
86 'api.Contact.getsingle' => array(
87 'id' => '$value.contact_id',
88 'return' => 'do_not_sms',
92 catch (CiviCRM_API3_Exception
$e) {
95 if (!$phone['api.Contact.getsingle']['do_not_sms'] && $phone['phone']) {
96 $url = 'civicrm/activity/sms/add';
102 elseif ($act['name'] == 'Print PDF Letter') {
103 $url = 'civicrm/activity/pdf/add';
105 elseif (!empty($act['filter']) ||
(!empty($act['component_id']) && $act['component_id'] != '1')) {
108 $act['url'] = CRM_Utils_System
::url($url,
109 "{$urlParams}{$act['value']}", FALSE, NULL, FALSE
111 $act +
= array('icon' => 'fa-plus-square-o');
112 $activityTypes[$act['value']] = $act;
115 $self->assign('activityTypes', $activityTypes);
117 $self->assign('suppressForm', TRUE);