本文整理汇总了PHP中CRM_Utils_Time类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Time类的具体用法?PHP CRM_Utils_Time怎么用?PHP CRM_Utils_Time使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Utils_Time类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testEquals
/**
* Test equals.
*
* @param string $timeA
* @param string $timeB
* @param int $threshold
* @param bool $expectedResult
*
* @dataProvider equalCases
*/
public function testEquals($timeA, $timeB, $threshold, $expectedResult)
{
$actual = CRM_Utils_Time::isEqual($timeA, $timeB, $threshold);
$this->assertEquals($expectedResult, $actual);
$actual = CRM_Utils_Time::isEqual($timeB, $timeA, $threshold);
$this->assertEquals($expectedResult, $actual);
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:17,代码来源:TimeTest.php
示例2: tearDown
public function tearDown()
{
unset($this->queue);
unset($this->queueService);
CRM_Utils_Time::resetTime();
$tablesToTruncate = array('civicrm_queue_item');
$this->quickCleanup($tablesToTruncate);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:8,代码来源:RunnerTest.php
示例3: testSequence
public function testSequence()
{
$actStatuses = array_flip(\CRM_Core_PseudoConstant::activityStatus('name'));
$caseStatuses = array_flip(\CRM_Case_PseudoConstant::caseStatus('name'));
// Create case; schedule first activity
\CRM_Utils_Time::setTime('2013-11-30 01:00:00');
$case = $this->callAPISuccess('case', 'create', $this->_params);
$analyzer = new \Civi\CCase\Analyzer($case['id']);
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Edit details of first activity -- but don't finish it yet!
\CRM_Utils_Time::setTime('2013-11-30 01:30:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'subject' => 'This is the new subject'));
$analyzer = new \Civi\CCase\Analyzer($case['id']);
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Complete first activity; schedule second
\CRM_Utils_Time::setTime('2013-11-30 02:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Complete second activity; schedule third
\CRM_Utils_Time::setTime('2013-11-30 03:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
// Complete third activity; close case
\CRM_Utils_Time::setTime('2013-11-30 04:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
$this->assertEquals($caseStatuses['Closed'], self::ag($analyzer->getCase(), 'status_id'));
// */
}
开发者ID:sdekok,项目名称:civicrm-core,代码行数:56,代码来源:SequenceListenerTest.php
示例4: checkMysqlTime
public function checkMysqlTime()
{
$messages = array();
$phpNow = date('Y-m-d H:i');
$sqlNow = CRM_Core_DAO::singleValueQuery("SELECT date_format(now(), '%Y-%m-%d %H:%i')");
if (!CRM_Utils_Time::isEqual($phpNow, $sqlNow, 2.5 * 60)) {
$messages[] = new CRM_Utils_Check_Message('checkMysqlTime', ts('Timestamps reported by MySQL (eg "%2") and PHP (eg "%3" ) are mismatched.<br /><a href="%1">Read more about this warning</a>', array(1 => CRM_Utils_System::getWikiBaseURL() . 'checkMysqlTime', 2 => $sqlNow, 3 => $phpNow)), ts('Environment Settings'));
}
return $messages;
}
开发者ID:hguru,项目名称:224Civi,代码行数:10,代码来源:Env.php
示例5: smarty_function_crmSigner
/**
* Generate a secure signature
*
* {code}
* {crmSigner var=mySig extra=123}
* var urlParams = ts={$mySig.ts}&extra={$mySig.extra}&sig={$mySig.signature}
* {endcode}
*
* @param $params array with keys:
* - var: string, a smarty variable to generate
* - ts: int, the current time (if omitted, autogenerated)
* - any other vars are put into the signature (sorted)
*/
function smarty_function_crmSigner($params, &$smarty)
{
$var = $params['var'];
unset($params['var']);
$params['ts'] = CRM_Utils_Time::getTimeRaw();
$fields = array_keys($params);
sort($fields);
$signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), $fields);
$params['signature'] = $signer->sign($params);
$smarty->assign($var, $params);
}
开发者ID:hguru,项目名称:224Civi,代码行数:24,代码来源:function.crmSigner.php
示例6: checkMysqlTime
/**
* Check that the MySQL time settings match the PHP time settings.
*
* @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings
*/
public function checkMysqlTime()
{
//CRM-19115 - Always set MySQL time before checking it.
CRM_Core_Config::singleton()->userSystem->setMySQLTimeZone();
$messages = array();
$phpNow = date('Y-m-d H:i');
$sqlNow = CRM_Core_DAO::singleValueQuery("SELECT date_format(now(), '%Y-%m-%d %H:%i')");
if (!CRM_Utils_Time::isEqual($phpNow, $sqlNow, 2.5 * 60)) {
$messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Timestamps reported by MySQL (eg "%2") and PHP (eg "%3" ) are mismatched.<br /><a href="%1">Read more about this warning</a>', array(1 => CRM_Utils_System::getWikiBaseURL() . 'checkMysqlTime', 2 => $sqlNow, 3 => $phpNow)), ts('Timestamp Mismatch'), \Psr\Log\LogLevel::ERROR, 'fa-server');
}
return $messages;
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:17,代码来源:Env.php
示例7: parseExpiration
/**
* Parse the expiration time from a series of HTTP headers.
*
* @param array $headers
* @return int|NULL
* Expiration tme as seconds since epoch, or NULL if not cacheable.
*/
public static function parseExpiration($headers)
{
$headers = CRM_Utils_Array::rekey($headers, function ($k, $v) {
return strtolower($k);
});
if (!empty($headers['cache-control'])) {
$cc = self::parseCacheControl($headers['cache-control']);
if ($cc['max-age'] && is_numeric($cc['max-age'])) {
return CRM_Utils_Time::getTimeRaw() + $cc['max-age'];
}
}
return NULL;
}
开发者ID:kidaa30,项目名称:yes,代码行数:20,代码来源:Http.php
示例8: stealItem
/**
* Get the next item, even if there's an active lease
*
* @param $lease_time seconds
*
* @return object with key 'data' that matches the inputted data
*/
function stealItem($lease_time = 3600)
{
$sql = "\n SELECT id, queue_name, submit_time, release_time, data\n FROM civicrm_queue_item\n WHERE queue_name = %1\n ORDER BY weight ASC, release_time ASC, id ASC\n LIMIT 1\n ";
$params = array(1 => array($this->getName(), 'String'));
$dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, 'CRM_Queue_DAO_QueueItem');
if ($dao->fetch()) {
$nowEpoch = CRM_Utils_Time::getTimeRaw();
CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = %1 WHERE id = %2", array('1' => array(date('YmdHis', $nowEpoch + $lease_time), 'String'), '2' => array($dao->id, 'Integer')));
$dao->data = unserialize($dao->data);
return $dao;
} else {
CRM_Core_Error::debug_var('no items found');
return FALSE;
}
}
开发者ID:alejandro-ixiam,项目名称:org.civicoop.civirules,代码行数:22,代码来源:Civirules.php
示例9: download
/**
* @param string $file
* Local file path.
* @param string $mimeType
* @param int $ttl
* Time to live (seconds).
*/
protected function download($file, $mimeType, $ttl)
{
if (!file_exists($file)) {
header("HTTP/1.0 404 Not Found");
return;
} elseif (!is_readable($file)) {
header('HTTP/1.0 403 Forbidden');
return;
}
CRM_Utils_System::setHttpHeader('Expires', gmdate('D, d M Y H:i:s \\G\\M\\T', CRM_Utils_Time::getTimeRaw() + $ttl));
CRM_Utils_System::setHttpHeader("Content-Type", $mimeType);
CRM_Utils_System::setHttpHeader("Content-Disposition", "inline; filename=\"" . basename($file) . "\"");
CRM_Utils_System::setHttpHeader("Cache-Control", "max-age={$ttl}, public");
CRM_Utils_System::setHttpHeader('Pragma', 'public');
readfile($file);
}
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:23,代码来源:ImageFile.php
示例10: send
/**
* @param string $verb
* @param string $url
* @param string $blob
* @param array $headers
* Array of headers (e.g. "Content-type" => "text/plain").
* @return array
* array($headers, $blob, $code)
*/
public function send($verb, $url, $blob, $headers = array())
{
$lowVerb = strtolower($verb);
if ($lowVerb === 'get' && $this->cache) {
$cachePath = 'get/' . md5($url);
$cacheLine = $this->cache->get($cachePath);
if ($cacheLine && $cacheLine['expires'] > CRM_Utils_Time::getTimeRaw()) {
return $cacheLine['data'];
}
}
$result = parent::send($verb, $url, $blob, $headers);
if ($lowVerb === 'get' && $this->cache) {
$expires = CRM_Utils_Http::parseExpiration($result[0]);
if ($expires !== NULL) {
$cachePath = 'get/' . md5($url);
$cacheLine = array('url' => $url, 'expires' => $expires, 'data' => $result);
$this->cache->set($cachePath, $cacheLine);
}
}
return $result;
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:30,代码来源:CiviCxnHttp.php
示例11: getDocument
/**
* Get the messages document (either from the cache or by downloading)
*
* @return NULL|array
*/
public function getDocument()
{
$isChanged = FALSE;
$document = $this->cache->get('communityMessages');
if (empty($document) || !is_array($document)) {
$document = array('messages' => array(), 'expires' => 0, 'ttl' => self::DEFAULT_RETRY, 'retry' => self::DEFAULT_RETRY);
$isChanged = TRUE;
}
if ($document['expires'] <= CRM_Utils_Time::getTimeRaw()) {
$newDocument = $this->fetchDocument();
if ($newDocument && $this->validateDocument($newDocument)) {
$document = $newDocument;
$document['expires'] = CRM_Utils_Time::getTimeRaw() + $document['ttl'];
} else {
// keep the old messages for now, try again later
$document['expires'] = CRM_Utils_Time::getTimeRaw() + $document['retry'];
}
$isChanged = TRUE;
}
if ($isChanged) {
$this->cache->set('communityMessages', $document);
}
return $document;
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:29,代码来源:CommunityMessages.php
示例12: delayAction
/**
* Save an action into a queue for delayed processing
*
* @param \DateTime $delayTo
* @param \CRM_Civirules_Action $action
* @param \CRM_Civirules_TriggerData_TriggerData $triggerData
*/
protected static function delayAction(DateTime $delayTo, CRM_Civirules_Action $action, CRM_Civirules_TriggerData_TriggerData $triggerData)
{
$queue = CRM_Queue_Service::singleton()->create(array('type' => 'Civirules', 'name' => self::QUEUE_NAME, 'reset' => false));
//create a task with the action and eventData as parameters
$task = new CRM_Queue_Task(array('CRM_Civirules_Engine', 'executeDelayedAction'), array($action, $triggerData));
//save the task with a delay
$dao = new CRM_Queue_DAO_QueueItem();
$dao->queue_name = $queue->getName();
$dao->submit_time = CRM_Utils_Time::getTime('YmdHis');
$dao->data = serialize($task);
$dao->weight = 0;
//weight, normal priority
$dao->release_time = $delayTo->format('YmdHis');
$dao->save();
}
开发者ID:alejandro-ixiam,项目名称:org.civicoop.civirules,代码行数:22,代码来源:Engine.php
示例13: assertCronRuns
/**
* Run a series of cron jobs and make an assertion about email deliveries.
*
* @param array $cronRuns
* array specifying when to run cron and what messages to expect; each item is an array with keys:
* - time: string, e.g. '2012-06-15 21:00:01'
* - recipients: array(array(string)), list of email addresses which should receive messages
*/
public function assertCronRuns($cronRuns)
{
foreach ($cronRuns as $cronRun) {
CRM_Utils_Time::setTime($cronRun['time']);
$this->callAPISuccess('job', 'send_reminder', array());
$this->mut->assertRecipients($cronRun['recipients']);
if (array_key_exists('subjects', $cronRun)) {
$this->mut->assertSubjects($cronRun['subjects']);
}
$this->mut->clearMessages();
}
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:20,代码来源:ActionScheduleTest.php
示例14: setDb
/**
* Update the DB record for this setting.
*
* @param string $name
* The simple name of the setting.
* @param mixed $value
* The new value of the setting.
*/
protected function setDb($name, $value)
{
if (\CRM_Core_BAO_Setting::isUpgradeFromPreFourOneAlpha1()) {
// civicrm_setting table is not going to be present.
return;
}
$fields = array();
$fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
//We haven't traditionally validated inputs to setItem, so this breaks things.
//foreach ($fieldsToSet as $settingField => &$settingValue) {
// self::validateSetting($settingValue, $fields['values'][$settingField]);
//}
$metadata = $fields['values'][$name];
$dao = new \CRM_Core_DAO_Setting();
$dao->name = $name;
$dao->domain_id = $this->domainId;
if ($this->contactId) {
$dao->contact_id = $this->contactId;
$dao->is_domain = 0;
} else {
$dao->is_domain = 1;
}
$dao->find(TRUE);
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
call_user_func(\Civi\Core\Resolver::singleton()->get($callback), unserialize($dao->value), $value, $metadata, $this->domainId);
}
}
if (!is_array($value) && \CRM_Utils_System::isNull($value)) {
$dao->value = 'null';
} else {
$dao->value = serialize($value);
}
if (!isset(\Civi::$statics[__CLASS__]['upgradeMode'])) {
\Civi::$statics[__CLASS__]['upgradeMode'] = \CRM_Core_Config::isUpgradeMode();
}
if (\Civi::$statics[__CLASS__]['upgradeMode'] && \CRM_Core_DAO::checkFieldExists('civicrm_setting', 'group_name')) {
$dao->group_name = 'placeholder';
}
$dao->created_date = \CRM_Utils_Time::getTime('YmdHis');
$session = \CRM_Core_Session::singleton();
if (\CRM_Contact_BAO_Contact_Utils::isContactId($session->get('userID'))) {
$dao->created_id = $session->get('userID');
}
if ($dao->id) {
$dao->save();
} else {
// Cannot use $dao->save(); in upgrade mode (eg WP + Civi 4.4=>4.7), the DAO will refuse
// to save the field `group_name`, which is required in older schema.
\CRM_Core_DAO::executeQuery(\CRM_Utils_SQL_Insert::dao($dao)->toSQL());
}
$dao->free();
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:61,代码来源:SettingsBag.php
示例15: setDb
/**
* Update the DB record for this setting.
*
* @param string $name
* The simple name of the setting.
* @param mixed $value
* The new value of the setting.
*/
protected function setDb($name, $value)
{
if (\CRM_Core_BAO_Setting::isUpgradeFromPreFourOneAlpha1()) {
// civicrm_setting table is not going to be present.
return;
}
$fields = array();
$fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
//We haven't traditionally validated inputs to setItem, so this breaks things.
//foreach ($fieldsToSet as $settingField => &$settingValue) {
// self::validateSetting($settingValue, $fields['values'][$settingField]);
//}
$metadata = $fields['values'][$name];
$dao = new \CRM_Core_DAO_Setting();
$dao->name = $name;
$dao->domain_id = $this->domainId;
if ($this->contactId) {
$dao->contact_id = $this->contactId;
$dao->is_domain = 0;
} else {
$dao->is_domain = 1;
}
$dao->find(TRUE);
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
call_user_func(\Civi\Core\Resolver::singleton()->get($callback), unserialize($dao->value), $value, $metadata, $this->domainId);
}
}
if (\CRM_Utils_System::isNull($value)) {
$dao->value = 'null';
} else {
$dao->value = serialize($value);
}
$dao->created_date = \CRM_Utils_Time::getTime('Ymdhis');
$session = \CRM_Core_Session::singleton();
if (\CRM_Contact_BAO_Contact_Utils::isContactId($session->get('userID'))) {
$dao->created_id = $session->get('userID');
}
$dao->save();
$dao->free();
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:49,代码来源:SettingsBag.php
示例16: processQueue
/**
* @param null $now
* @param array $params
*
* @return array
*/
static function processQueue($now = NULL, $params = array())
{
$now = $now ? CRM_Utils_Time::setTime($now) : CRM_Utils_Time::getTime();
$mappings = self::getMapping();
foreach ($mappings as $mappingID => $mapping) {
self::buildRecipientContacts($mappingID, $now, $params);
self::sendMailings($mappingID, $now);
}
$result = array('is_error' => 0, 'messages' => ts('Sent all scheduled reminders successfully'));
return $result;
}
开发者ID:ruchirapingale,项目名称:civicrm-core,代码行数:17,代码来源:ActionSchedule.php
示例17: checkToken
/**
* @param string $token
* A token supplied by the user.
* @return bool
* TRUE if the token is valid for submitting attachments
* @throws Exception
*/
public static function checkToken($token)
{
list($signature, $ts) = explode(';;;', $token);
$signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts'));
if (!is_numeric($ts) || CRM_Utils_Time::getTimeRaw() > $ts + self::ATTACHMENT_TOKEN_TTL) {
return FALSE;
}
return $signer->validate($signature, array('for' => 'crmAttachment', 'ts' => $ts));
}
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:16,代码来源:Attachment.php
示例18: testDefault
/**
* Execute the default schedule, without any special recipient selections.
*
* @dataProvider createTestCases
*
* @param string $targetDate
* @param string $setupFuncs
* @param array $expectMessages
*
* @throws \Exception
*/
public function testDefault($targetDate, $setupFuncs, $expectMessages)
{
$this->targetDate = $targetDate;
foreach (explode(' ', $setupFuncs) as $setupFunc) {
$this->{$setupFunc}();
}
$this->schedule->save();
$actualMessages = array();
foreach ($this->cronTimes() as $time) {
\CRM_Utils_Time::setTime($time);
$this->callAPISuccess('job', 'send_reminder', array());
foreach ($this->mut->getAllMessages('ezc') as $message) {
/** @var \ezcMail $message */
$simpleMessage = array('time' => $time, 'to' => \CRM_Utils_Array::collect('email', $message->to), 'subject' => $message->subject);
sort($simpleMessage['to']);
$actualMessages[] = $simpleMessage;
$this->mut->clearMessages();
}
}
$errorText = "Incorrect messages: " . print_r(array('actualMessages' => $actualMessages, 'expectMessages' => $expectMessages), 1);
$this->assertEquals(count($expectMessages), count($actualMessages), $errorText);
usort($expectMessages, array(__CLASS__, 'compareSimpleMsgs'));
usort($actualMessages, array(__CLASS__, 'compareSimpleMsgs'));
foreach ($expectMessages as $offset => $expectMessage) {
$actualMessage = $actualMessages[$offset];
$this->assertApproxEquals(strtotime($expectMessage['time']), strtotime($actualMessage['time']), $this->dateTolerance, $errorText);
if (isset($expectMessage['to'])) {
sort($expectMessage['to']);
$this->assertEquals($expectMessage['to'], $actualMessage['to'], $errorText);
}
if (isset($expectMessage['subject'])) {
$this->assertRegExp($expectMessage['subject'], $actualMessage['subject'], $errorText);
}
}
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:46,代码来源:AbstractMappingTest.php
示例19: checkUserName
/**
*Function to check the CMS username
*
*/
public static function checkUserName()
{
$signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts'));
if (CRM_Utils_Time::getTimeRaw() > $_REQUEST['ts'] + self::CHECK_USERNAME_TTL || $_REQUEST['for'] != 'civicrm/ajax/cmsuser' || !$signer->validate($_REQUEST['sig'], $_REQUEST)) {
$user = array('name' => 'error');
echo json_encode($user);
CRM_Utils_System::civiExit();
}
$config = CRM_Core_Config::singleton();
$username = trim($_REQUEST['cms_name']);
$params = array('name' => $username);
$errors = array();
$config->userSystem->checkUserNameEmailExists($params, $errors);
if (isset($errors['cms_name']) || isset($errors['name'])) {
//user name is not availble
$user = array('name' => 'no');
echo json_encode($user);
} else {
//user name is available
$user = array('name' => 'yes');
echo json_encode($user);
}
CRM_Utils_System::civiExit();
}
开发者ID:hguru,项目名称:224Civi,代码行数:28,代码来源:AJAX.php
示例20: createMailingActivity
/**
* Save a record about the delivery of a reminder email.
*
* WISHLIST: Instead of saving $actionSchedule->body_html, call this immediately after
* sending the message and pass in the fully rendered text of the message.
*
* @param CRM_Core_DAO_ActionSchedule $actionSchedule
* @param Civi\ActionSchedule\Mapping $mapping
* @param int $contactID
* @param int $entityID
* @param int|NULL $caseID
* @throws CRM_Core_Exception
*/
protected static function createMailingActivity($actionSchedule, $mapping, $contactID, $entityID, $caseID)
{
$session = CRM_Core_Session::singleton();
if ($mapping->getEntity() == 'civicrm_membership') {
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Membership Renewal Reminder', 'name');
} else {
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Reminder Sent', 'name');
}
$activityParams = array('subject' => $actionSchedule->title, 'details' => $actionSchedule->body_html, 'source_contact_id' => $session->get('userID') ? $session->get('userID') : $contactID, 'target_contact_id' => $contactID, 'activity_date_time' => CRM_Utils_Time::getTime('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'activity_type_id' => $activityTypeID, 'source_record_id' => $entityID);
$activity = CRM_Activity_BAO_Activity::create($activityParams);
//file reminder on case if source activity is a case activity
if (!empty($caseID)) {
$caseActivityParams = array();
$caseActivityParams['case_id'] = $caseID;
$caseActivityParams['activity_id'] = $activity->id;
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
}
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:31,代码来源:ActionSchedule.php
注:本文中的CRM_Utils_Time类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论