4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
22 namespace Civi\Api4\Action\Contact
;
24 use Civi\Api4\Generic\Result
;
27 * Generate a security checksum for anonymous access to CiviCRM.
29 * @method $this setContactId(int $cid) Set contact ID (required)
30 * @method int getContactId() Get contact ID param
31 * @method $this setTtl(int $ttl) Set TTL param
32 * @method int getTtl() Get TTL param
34 class GetChecksum
extends \Civi\Api4\Generic\AbstractAction
{
45 * Expiration time (hours). Defaults to 168 (24 * [7 or value of checksum_timeout system setting]).
47 * Set to 0 for infinite.
51 protected $ttl = NULL;
54 * @param \Civi\Api4\Generic\Result $result
56 public function _run(Result
$result) {
57 $ttl = ($this->ttl
=== 0 ||
$this->ttl
=== '0') ?
'inf' : $this->ttl
;
59 'id' => $this->contactId
,
60 'checksum' => \CRM_Contact_BAO_Contact_Utils
::generateChecksum($this->contactId
, NULL, $ttl),