12a9dc45a4a720774734e4ccfd1562717ac4ba93
3 +--------------------------------------------------------------------+
4 | CiviCRM Widget Creation Interface (WCI) Version 1.0 |
5 +--------------------------------------------------------------------+
6 | Copyright Zyxware Technologies (c) 2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM WCI. |
10 | CiviCRM WCI is free software; you can copy, modify, and distribute |
11 | it under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007. |
14 | CiviCRM WCI is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact Zyxware |
21 | Technologies at info[AT]zyxware[DOT]com. |
22 +--------------------------------------------------------------------+
28 * @copyright CiviCRM LLC (c) 2004-2013
32 class CRM_Wci_BAO_WidgetCache
extends CRM_Wci_DAO_WidgetCache
{
34 public static function setWidgetCache($widgetId, $widget) {
36 $expire_on = PHP_INT_MAX
;
37 if ($widget['dynamic'] == TRUE) {
38 $cacheTime = civicrm_api3('setting', 'getValue',
39 array('group' => 'Wci Preference', 'name' => 'widget_cache_timeout'));
40 $expire_on = $timenow +
($cacheTime * 60);
42 $query = "INSERT INTO civicrm_wci_widget_cache (widget_id, widget_code, expire, createdtime)
43 VALUES (%1, %2, %3, %4)
44 ON DUPLICATE KEY UPDATE widget_id = %1, widget_code = %2, expire = %3, createdtime = %4";
46 1 => array($widgetId, 'Integer'),
47 2 => array($widget['code'], 'String'),
48 3 => array($expire_on, 'Integer'),
49 4 => array($timenow, 'Integer')
51 CRM_Core_DAO
::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_WidgetCache');
54 public static function getWidgetCache($widgetId) {
56 $query = "SELECT widget_code FROM civicrm_wci_widget_cache where widget_id = %1
58 $dao = CRM_Core_DAO
::executeQuery($query, array(1 => array($widgetId, 'Integer'),
59 2 => array(time(), 'Integer')), TRUE, 'CRM_Wci_DAO_WidgetCache');
61 $code = $dao->widget_code
;
66 public static function deleteWidgetCache($widgetId) {
68 $query = "DELETE FROM civicrm_wci_widget_cache where widget_id = %1";
69 $dao = CRM_Core_DAO
::executeQuery($query,
70 array(1 => array($widgetId, 'Integer')), TRUE, 'CRM_Wci_DAO_WidgetCache');