當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Core_BAO_Setting::flushCache方法代碼示例

本文整理匯總了PHP中CRM_Core_BAO_Setting::flushCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_BAO_Setting::flushCache方法的具體用法?PHP CRM_Core_BAO_Setting::flushCache怎麽用?PHP CRM_Core_BAO_Setting::flushCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Core_BAO_Setting的用法示例。


在下文中一共展示了CRM_Core_BAO_Setting::flushCache方法的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);
 }
開發者ID:rajeshrhino,項目名稱:civicrm-core,代碼行數:44,代碼來源:AJAX.php

示例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();
 }
開發者ID:kidaa30,項目名稱:yes,代碼行數:46,代碼來源:AJAX.php

示例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");
 }
開發者ID:archcidburnziso,項目名稱:civicrm-core,代碼行數:38,代碼來源:SettingTest.php


注:本文中的CRM_Core_BAO_Setting::flushCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。