3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | 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 and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
35 class CRM_Wci_BAO_Widget
extends CRM_Wci_DAO_Widget
{
40 function __construct() {
41 parent
::__construct();
45 * Function to create a Widget
46 * takes an associative array and creates a Widget object
48 * This function is invoked from within the web form layer and also from the api layer
50 * @param array $params (reference ) an assoc array of name/value pairs
52 * @return object CRM_Wci_BAO_Widget object
56 static function create(array $params) {
58 // check required params
59 if (!self
::dataExists($params)) {
60 CRM_Core_Error
::fatal('Not enough data to create a widget.');
63 $widget = new CRM_Wci_BAO_Widget();
64 $widget->copyValues($params);
72 * Get a list of Widgets matching the params, where params keys are column
73 * names of civicrm_wci_widget.
75 * @param array $params
76 * @return array of CRM_Wci_BAO_Widget objects
78 static function retrieve(array $params) {
81 $widget = new CRM_Wci_BAO_Widget();
82 $widget->copyValues($params);
85 while ($widget->fetch()) {
86 $result[(int) $widget->id
] = clone $widget;
95 * Wrapper method for retrieve
97 * @param mixed $id Int or int-like string representing widget ID
98 * @return CRM_Wci_BAO_Widget
100 static function retrieveByID($id) {
101 if (!is_int($id) && !ctype_digit($id)) {
102 CRM_Core_Error
::fatal(__CLASS__
. '::' . __FUNCTION__
. ' expects an integer.');
106 $widgets = self
::retrieve(array('id' => $id));
108 if (!array_key_exists($id, $widgets)) {
109 CRM_Core_Error
::fatal("No widget with ID $id exists.");
112 return $widgets[$id];
116 * Check if there is absolute minimum of data to add the object
118 * @param array $params (reference ) an assoc array of name/value pairs
123 public static function dataExists($params) {
124 if (CRM_Utils_Array
::value('title', $params)) {