3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Auxiliary class to provide support for locking (and ignoring locks on) contact records.
21 class CRM_Contact_Form_Edit_Lock
{
24 * Build the form object.
26 * @param CRM_Core_Form $form
29 public static function buildQuickForm(&$form) {
30 $form->addField('modified_date', ['type' => 'hidden', 'id' => 'modified_date', 'label' => '']);
34 * Ensure that modified_date has not changed in the underlying DB.
36 * @param array $fields
37 * The input form values.
39 * The uploaded files if any.
40 * @param int $contactID
43 * true if no errors, else array of errors
45 public static function formRule($fields, $files, $contactID = NULL) {
48 $timestamps = CRM_Contact_BAO_Contact
::getTimestamps($contactID);
49 if ($fields['modified_date'] != $timestamps['modified_date']) {
50 // Inline buttons generated via JS
51 $open = sprintf("<span id='update_modified_date' data:latest_modified_date='%s'>", $timestamps['modified_date']);
53 $errors['modified_date'] = $open . ts('This record was modified by another user!') . $close;
56 return empty($errors) ?
TRUE : $errors;