31603 progress bar update not clearing widget cache
[com.zyxware.civiwci.git] / CRM / Wci / BAO / WidgetCache.php
index 12a9dc45a4a720774734e4ccfd1562717ac4ba93..85743682cec06950953c48eea49b7229f757522f 100644 (file)
@@ -69,4 +69,13 @@ class CRM_Wci_BAO_WidgetCache extends CRM_Wci_DAO_WidgetCache {
     $dao = CRM_Core_DAO::executeQuery($query,
       array(1 => array($widgetId, 'Integer')), TRUE, 'CRM_Wci_DAO_WidgetCache');
   }
+
+  public static function clearCache($pbId) {
+    $query = "SELECT wc.widget_id FROM civicrm_wci_widget_cache as wc INNER JOIN civicrm_wci_widget w on w.id = wc.widget_id WHERE w.progress_bar_id =%1";
+    $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($pbId, 'Integer')), TRUE, 'CRM_Wci_DAO_WidgetCache');
+    if ($dao->fetch()) {
+      $widget_id = $dao->widget_id;
+      CRM_Wci_BAO_WidgetCache::deleteWidgetCache($widget_id);
+    }
+  }
 }