(NFC) (dev/core#878) Simplify copyright header (CRM/*)
[civicrm-core.git] / CRM / Friend / BAO / Friend.php
index 0daf23ae528e0a4c062752dc30797f24ef040fe5..773009cb28dba67b29fad787bd6802ea521214cb 100644 (file)
@@ -1,34 +1,18 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ | Copyright CiviCRM LLC. All rights reserved.                        |
  |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
  */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
  *
  */
 
@@ -64,7 +48,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
    * @return int
    */
   public static function add(&$params) {
-    return CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
+    return CRM_Contact_BAO_Contact::createProfileContact($params);
   }
 
   /**
@@ -98,18 +82,18 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
   public static function create(&$params) {
     $transaction = new CRM_Core_Transaction();
 
-    $mailParams = array();
-    $contactParams = array();
+    $mailParams = [];
+    $contactParams = [];
 
     // create contact corresponding to each friend
     foreach ($params['friend'] as $key => $details) {
       if ($details["first_name"]) {
-        $contactParams[$key] = array(
+        $contactParams[$key] = [
           'first_name' => $details["first_name"],
           'last_name' => $details["last_name"],
           'contact_source' => ts('Tell a Friend') . ": {$params['title']}",
           'email-Primary' => $details["email"],
-        );
+        ];
 
         $displayName = $details["first_name"] . " " . $details["last_name"];
         $mailParams['email'][$displayName] = $details["email"];
@@ -125,7 +109,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
     $activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', 'Tell a Friend', 'value', 'name');
 
     // create activity
-    $activityParams = array(
+    $activityParams = [
       'source_contact_id' => $params['source_contact_id'],
       'source_record_id' => NULL,
       'activity_type_id' => $activityTypeId,
@@ -136,7 +120,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
       'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'),
       'is_test' => $params['is_test'],
       'campaign_id' => CRM_Utils_Array::value('campaign_id', $params),
-    );
+    ];
 
     // activity creation
     $activity = CRM_Activity_BAO_Activity::create($activityParams);
@@ -147,18 +131,18 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
     foreach ($contactParams as $key => $value) {
       // create contact only if it does not exits in db
       $value['email'] = $value['email-Primary'];
-      $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($value, 'Individual', 'Supervised', array(), FALSE);
+      $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($value, 'Individual', 'Supervised', [], FALSE);
 
       if (!$contactID) {
         $contactID = self::add($value);
       }
 
       // attempt to save activity targets
-      $targetParams = array(
+      $targetParams = [
         'activity_id' => $activity->id,
         'contact_id' => $contactID,
         'record_type_id' => $targetID,
-      );
+      ];
 
       // See if it already exists
       $activityContact = new CRM_Activity_DAO_ActivityContact();
@@ -181,11 +165,11 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
     list($_, $mailParams['email_from']) = CRM_Core_BAO_Domain::getNameAndEmail();
     list($username, $mailParams['domain']) = explode('@', $mailParams['email_from']);
 
-    $default = array();
-    $findProperties = array('id' => $params['entity_id']);
+    $default = [];
+    $findProperties = ['id' => $params['entity_id']];
 
     if ($params['entity_table'] == 'civicrm_contribution_page') {
-      $returnProperties = array('receipt_from_email', 'is_email_receipt');
+      $returnProperties = ['receipt_from_email', 'is_email_receipt'];
       CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage',
         $findProperties,
         $default,
@@ -201,7 +185,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
       $mailParams['module'] = 'contribute';
     }
     elseif ($params['entity_table'] == 'civicrm_event') {
-      $returnProperties = array('confirm_from_email', 'is_email_confirm');
+      $returnProperties = ['confirm_from_email', 'is_email_confirm'];
       CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event',
         $findProperties,
         $default,
@@ -241,12 +225,12 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
    * @return void
    */
   public static function buildFriendForm($form) {
-    $form->addElement('checkbox', 'tf_is_active', ts('Tell a Friend enabled?'), NULL, array('onclick' => "friendBlock(this)"));
+    $form->addElement('checkbox', 'tf_is_active', ts('Tell a Friend enabled?'), NULL, ['onclick' => "friendBlock(this)"]);
     // name
     $form->add('text', 'tf_title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'title'), TRUE);
 
     // intro-text and thank-you text
-    $form->add('wysiwyg', 'intro', ts('Introduction'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'intro') + array('class' => 'collapsed'));
+    $form->add('wysiwyg', 'intro', ts('Introduction'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'intro') + ['class' => 'collapsed']);
 
     $form->add('textarea', 'suggested_message', ts('Suggested Message'),
       CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'suggested_message'), FALSE
@@ -256,7 +240,7 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
 
     $form->add('text', 'tf_thankyou_title', ts('Thank-you Title'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'thankyou_title'), TRUE);
 
-    $form->add('wysiwyg', 'tf_thankyou_text', ts('Thank-you Message'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'thankyou_text') + array('class' => 'collapsed'));
+    $form->add('wysiwyg', 'tf_thankyou_text', ts('Thank-you Message'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'thankyou_text') + ['class' => 'collapsed']);
 
     if ($form->_friendId) {
       // CRM-14200 the i18n dialogs need this for translation
@@ -313,21 +297,21 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend {
       $values['domain'] = $domainFromName;
     }
 
-    $templateParams = array(
+    $templateParams = [
       'groupName' => 'msg_tpl_workflow_friend',
       'valueName' => 'friend',
       'contactId' => $contactID,
-      'tplParams' => array(
+      'tplParams' => [
         $values['module'] => $values['module'],
         'senderContactName' => $fromName,
         'title' => $values['title'],
         'generalLink' => $values['general_link'],
         'pageURL' => $values['page_url'],
         'senderMessage' => $values['message'],
-      ),
+      ],
       'from' => "$fromName (via {$values['domain']}) <{$values['email_from']}>",
       'replyTo' => $email,
-    );
+    ];
 
     foreach ($values['email'] as $displayName => $emailTo) {
       if ($emailTo) {