本文整理汇总了PHP中CRM_Contact_BAO_Contact::getTimestamps方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::getTimestamps方法的具体用法?PHP CRM_Contact_BAO_Contact::getTimestamps怎么用?PHP CRM_Contact_BAO_Contact::getTimestamps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::getTimestamps方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formRule
/**
* Ensure that modified_date hasn't changed in the underlying DB
*
* @param array $fields the input form values
* @param array $files the uploaded files if any
* @param array $options additional user data
*
* @return true if no errors, else array of errors
* @access public
* @static
*/
static function formRule($fields, $files, $contactID = NULL)
{
$errors = array();
$timestamps = CRM_Contact_BAO_Contact::getTimestamps($contactID);
if ($fields['modified_date'] != $timestamps['modified_date']) {
// Inline buttons generated via JS
$open = sprintf("<span id='update_modified_date' data:latest_modified_date='%s'>", $timestamps['modified_date']);
$close = "</span>";
$errors['modified_date'] = $open . ts('This record was modified by another user!') . $close;
}
return empty($errors) ? TRUE : $errors;
}
示例2: _testTimestamps
/**
* Helper for testing timestamp manipulation.
*
* Create a contact and perform a series of steps with it; after each
* step, ensure that the contact's modified_date has increased.
*
* @param array $callbacks
* ($name => $callable).
*/
public function _testTimestamps($callbacks)
{
CRM_Core_DAO::triggerRebuild();
$contactId = $this->individualCreate();
$origTimestamps = CRM_Contact_BAO_Contact::getTimestamps($contactId);
$this->assertRegexp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d /', $origTimestamps['created_date']);
$this->assertRegexp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d /', $origTimestamps['modified_date']);
$this->assertTrue($origTimestamps['created_date'] <= $origTimestamps['modified_date']);
$prevTimestamps = $origTimestamps;
foreach ($callbacks as $callbackName => $callback) {
sleep(1);
// advance clock by 1 second to ensure timestamps change
$callback($contactId);
$newTimestamps = CRM_Contact_BAO_Contact::getTimestamps($contactId);
$this->assertRegexp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d /', $newTimestamps['created_date'], "Malformed created_date (after {$callbackName})");
$this->assertRegexp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d /', $newTimestamps['modified_date'], "Malformed modified_date (after {$callbackName})");
$this->assertEquals($origTimestamps['created_date'], $newTimestamps['created_date'], "Changed created_date (after {$callbackName})");
$this->assertTrue($prevTimestamps['modified_date'] < $newTimestamps['modified_date'], "Misordered modified_date (after {$callbackName})");
$prevTimestamps = $newTimestamps;
}
$this->contactDelete($contactId);
}
示例3: getResponse
/**
* Return any post-save data.
*
* @param int $contactID
*
* @return array
* extra options to return in JSON
*/
public static function getResponse($contactID)
{
$timestamps = CRM_Contact_BAO_Contact::getTimestamps($contactID);
return array('oplock_ts' => $timestamps['modified_date']);
}