本文整理汇总了PHP中CRM_Core_BAO_Setting::inCache方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Setting::inCache方法的具体用法?PHP CRM_Core_BAO_Setting::inCache怎么用?PHP CRM_Core_BAO_Setting::inCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Setting
的用法示例。
在下文中一共展示了CRM_Core_BAO_Setting::inCache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContactActivity
public static function getContactActivity()
{
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
$sortMapper = array();
foreach ($_GET['columns'] as $key => $value) {
$sortMapper[$key] = $value['data'];
}
$offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
$rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
$sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
$sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
$params = $_GET;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['contact_id'] = $contactID;
$params['context'] = $context;
// get the contact activities
$activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
foreach ($activities as $key => $value) {
//Check if recurring activity
if (!empty($value['is_recurring_activity'])) {
$repeat = $value['is_recurring_activity'];
$activities[$key]['activity_type'] .= '<br/><span class="bold">' . ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])) . '</span>';
}
}
// store the activity filter preference CRM-11761
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID) {
//flush cache before setting filter to account for global cache (memcache)
$domainID = CRM_Core_Config::domainID();
$cacheKey = CRM_Core_BAO_Setting::inCache(CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'activity_tab_filter', NULL, $userID, TRUE, $domainID, TRUE);
if ($cacheKey) {
CRM_Core_BAO_Setting::flushCache($cacheKey);
}
$activityFilter = array('activity_type_filter_id' => empty($params['activity_type_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_id'], 'Integer'), 'activity_type_exclude_filter_id' => empty($params['activity_type_exclude_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_exclude_id'], 'Integer'));
CRM_Core_BAO_Setting::setItem($activityFilter, CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'activity_tab_filter', NULL, $userID, $userID);
}
CRM_Utils_JSON::output($activities);
}
示例2: getContactActivity
public static function getContactActivity()
{
$contactID = CRM_Utils_Type::escape($_POST['contact_id'], 'Integer');
$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
$sortMapper = array(0 => 'activity_type', 1 => 'subject', 2 => 'source_contact_name', 3 => '', 4 => '', 5 => 'activity_date_time', 6 => 'status_id');
$sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
$offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
$rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
$sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
$sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
$params = $_POST;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = $offset / $rowCount + 1;
$params['rp'] = $rowCount;
$params['contact_id'] = $contactID;
$params['context'] = $context;
// get the contact activities
$activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
foreach ($activities as $key => $value) {
//Check if recurring activity
if (!empty($value['is_recurring_activity'])) {
$repeat = $value['is_recurring_activity'];
$activities[$key]['activity_type'] .= '<br/><span class="bold">' . ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])) . '</span>';
}
}
// store the activity filter preference CRM-11761
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID) {
//flush cache before setting filter to account for global cache (memcache)
$domainID = CRM_Core_Config::domainID();
$cacheKey = CRM_Core_BAO_Setting::inCache(CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'activity_tab_filter', NULL, $userID, TRUE, $domainID, TRUE);
if ($cacheKey) {
CRM_Core_BAO_Setting::flushCache($cacheKey);
}
$activityFilter = array('activity_type_filter_id' => empty($params['activity_type_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_id'], 'Integer'), 'activity_type_exclude_filter_id' => empty($params['activity_type_exclude_id']) ? '' : CRM_Utils_Type::escape($params['activity_type_exclude_id'], 'Integer'));
CRM_Core_BAO_Setting::setItem($activityFilter, CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'activity_tab_filter', NULL, $userID, $userID);
}
$iFilteredTotal = $iTotal = $params['total'];
$selectorElements = array('activity_type', 'subject', 'source_contact', 'target_contact', 'assignee_contact', 'activity_date', 'status', 'links', 'class');
header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
示例3: testConvertAndFillSettings
/**
* This test checks that CRM_Core_BAO_Setting::updateSettingsFromMetaData();
* 1) Removes 'maxAttachments' from config (because 'prefetch' is not set in the metadata it should
* be removed
* 2) for current domain setting max_attachments is set to the value that $config->maxAttachments
* had (6)
* 3) for other domain (2) max_attachments is set to the configured default (3)
*
*
**/
function testConvertAndFillSettings()
{
$settings = array('maxAttachments' => 6);
CRM_Core_BAO_ConfigSetting::add($settings);
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$this->assertEquals(6, $config->maxAttachments);
$checkSQL = "SELECT count(*) FROM civicrm_domain WHERE config_backend LIKE '%\"maxAttachments\";i:6%' AND id = 1\n ";
$checkresult = CRM_Core_DAO::singleValueQuery($checkSQL);
$this->assertEquals(1, $checkresult, "Check that maxAttachments has been saved to database not just stored in config");
$sql = " DELETE FROM civicrm_setting WHERE name = 'max_attachments'";
CRM_Core_DAO::executeQuery($sql);
$currentDomain = CRM_Core_Config::domainID();
// we are setting up an artificial situation here as we are trying to drive out
// previous memory of this setting so we need to flush it out
$cachekey = CRM_Core_BAO_Setting::inCache('CiviCRM Preferences', 'max_attachments', NULL, NULL, TRUE, $currentDomain);
CRM_Core_BAO_Setting::flushCache($cachekey);
CRM_Core_BAO_Setting::updateSettingsFromMetaData();
//check current domain
$value = civicrm_api('setting', 'getvalue', array('version' => 3, 'name' => 'max_attachments', 'group' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME));
$this->assertEquals(6, $value);
// check alternate domain
$value = civicrm_api('setting', 'getvalue', array('version' => 3, 'name' => 'max_attachments', 'group' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'domain_id' => 2));
$this->assertEquals(3, $value);
//some caching inconsistency here
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$maxAttachments = empty($config->maxAttachments) ? NULL : $config->maxAttachments;
$this->assertEmpty($maxAttachments, "Config item still Set to {$maxAttachments}\n . This works fine when test run alone");
}