Beta 2 bug fixes. 31243. added agpl license and widget cache feature
[com.zyxware.civiwci.git] / CRM / Wci / DAO / WidgetCache.php
diff --git a/CRM/Wci/DAO/WidgetCache.php b/CRM/Wci/DAO/WidgetCache.php
new file mode 100644 (file)
index 0000000..379385e
--- /dev/null
@@ -0,0 +1,255 @@
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 4.4                                                |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2013                                |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM.                                    |
+|                                                                    |
+| CiviCRM is free software; you can copy, modify, and distribute it  |
+| under the terms of the GNU Affero General Public License           |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+|                                                                    |
+| CiviCRM is distributed in the hope that it will be useful, but     |
+| WITHOUT ANY WARRANTY; without even the implied warranty of         |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+| See the GNU Affero General Public License for more details.        |
+|                                                                    |
+| You should have received a copy of the GNU Affero General Public   |
+| License and the CiviCRM Licensing Exception along                  |
+| with this program; if not, contact CiviCRM LLC                     |
+| at info[AT]civicrm[DOT]org. If you have questions about the        |
+| GNU Affero General Public License or the licensing of CiviCRM,     |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
++--------------------------------------------------------------------+
+*/
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ */
+class CRM_Wci_DAO_WidgetCache extends CRM_Core_DAO
+{
+  /**
+   * static instance to hold the table name
+   *
+   * @var string
+   * @static
+   */
+  static $_tableName = 'civicrm_wci_widget_cache';
+  /**
+   * static instance to hold the field values
+   *
+   * @var array
+   * @static
+   */
+  static $_fields = null;
+  /**
+   * static instance to hold the keys used in $_fields for each field.
+   *
+   * @var array
+   * @static
+   */
+  static $_fieldKeys = null;
+  /**
+   * static instance to hold the FK relationships
+   *
+   * @var string
+   * @static
+   */
+  static $_links = null;
+  /**
+   * static instance to hold the values that can
+   * be imported
+   *
+   * @var array
+   * @static
+   */
+  static $_import = null;
+  /**
+   * static instance to hold the values that can
+   * be exported
+   *
+   * @var array
+   * @static
+   */
+  static $_export = null;
+  /**
+   * static value to see if we should log any modifications to
+   * this table in the civicrm_log table
+   *
+   * @var boolean
+   * @static
+   */
+  static $_log = true;
+  /**
+   * cache id
+   *
+   * @var int unsigned
+   */
+  public $id;
+  /**
+   * widget code
+   *
+   * @var string
+   */
+  public $widget_code;
+  /**
+   * widget id
+   *
+   * @var float
+   */
+  public $widget_id;
+  /**
+   * time stamp
+   *
+   * @var float
+   */
+  public $ts;
+  
+  function __construct()
+  {
+    $this->__table = 'civicrm_wci_widget_cache';
+    parent::__construct();
+  }
+  /**
+   * return foreign keys and entity references
+   *
+   * @static
+   * @access public
+   * @return array of CRM_Core_EntityReference
+   */
+  static function getReferenceColumns()
+  {
+    return self::$_links;
+  }
+  /**
+   * returns all the column names of this table
+   *
+   * @access public
+   * @return array
+   */
+  static function &fields()
+  {
+    if (!(self::$_fields)) {
+      self::$_fields = array(
+        'widget_cache_id' => array(
+          'name' => 'id',
+          'type' => CRM_Utils_Type::T_INT,
+          'title' => ts('cahce Id', array('domain' => 'org.civicrm.wci')) ,
+          'required' => true,
+        ) ,
+        'widget_id' => array(
+          'name' => 'widget_id',
+          'type' => CRM_Utils_Type::T_INT,
+          'required' => false,
+        ) ,
+        'widget_code' => array(
+          'name' => 'widget_code',
+          'type' => CRM_Utils_Type::T_TEXT,
+          'title' => ts('widget code', array('domain' => 'org.civicrm.wci')) ,
+          'required' => false,
+        ) ,
+        'ts' => array(
+          'name' => 'ts',
+          'type' => CRM_Utils_Type::T_TIMESTAMP,
+          'title' => ts('timestamp', array('domain' => 'org.civicrm.wci')) ,
+          'required' => false,
+          'maxlength' => 64,
+        ) ,
+
+
+      );
+    }
+    return self::$_fields;
+  }
+  /**
+   * Returns an array containing, for each field, the arary key used for that
+   * field in self::$_fields.
+   *
+   * @access public
+   * @return array
+   */
+  static function &fieldKeys()
+  {
+    if (!(self::$_fieldKeys)) {
+      self::$_fieldKeys = array(
+        'id' => 'widget_cache_id',
+        'widget_id' => 'widget_id',
+        'widget_code' => 'widget_code',
+        'ts' => 'ts',
+      );
+    }
+    return self::$_fieldKeys;
+  }
+  /**
+   * returns the names of this table
+   *
+   * @access public
+   * @static
+   * @return string
+   */
+  static function getTableName()
+  {
+    return self::$_tableName;
+  }
+  /**
+   * returns if this table needs to be logged
+   *
+   * @access public
+   * @return boolean
+   */
+  function getLog()
+  {
+    return self::$_log;
+  }
+  /**
+   * returns the list of fields that can be imported
+   *
+   * @access public
+   * return array
+   * @static
+   */
+  static function &import($prefix = false)
+  {
+    if (!(self::$_import)) {
+      self::$_import = array();
+      $fields = self::fields();
+      foreach($fields as $name => $field) {
+        if (CRM_Utils_Array::value('import', $field)) {
+          if ($prefix) {
+            self::$_import['wci_progress_bar'] = & $fields[$name];
+          } else {
+            self::$_import[$name] = & $fields[$name];
+          }
+        }
+      }
+    }
+    return self::$_import;
+  }
+  /**
+   * returns the list of fields that can be exported
+   *
+   * @access public
+   * return array
+   * @static
+   */
+  static function &export($prefix = false)
+  {
+    if (!(self::$_export)) {
+      self::$_export = array();
+      $fields = self::fields();
+      foreach($fields as $name => $field) {
+        if (CRM_Utils_Array::value('export', $field)) {
+          if ($prefix) {
+            self::$_export['wci_progress_bar'] = & $fields[$name];
+          } else {
+            self::$_export[$name] = & $fields[$name];
+          }
+        }
+      }
+    }
+    return self::$_export;
+  }
+}