Merge pull request #8042 from jitendrapurohit/CRM-18250
[civicrm-core.git] / CRM / Upgrade / Snapshot / V4p2 / Price / DAO / SetEntity.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27 /**
28 *
29 * @package CRM
30 * @copyright CiviCRM LLC (c) 2004-2016
31 * $Id$
32 *
33 */
34 require_once 'CRM/Core/DAO.php';
35 require_once 'CRM/Utils/Type.php';
36
37 /**
38 * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity
39 */
40 class CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity extends CRM_Core_DAO {
41 /**
42 * static instance to hold the table name
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_price_set_entity';
47 /**
48 * static instance to hold the field values
49 *
50 * @var array
51 */
52 static $_fields = NULL;
53 /**
54 * static instance to hold the FK relationships
55 *
56 * @var string
57 */
58 static $_links = NULL;
59 /**
60 * static instance to hold the values that can
61 * be imported
62 *
63 * @var array
64 */
65 static $_import = NULL;
66 /**
67 * static instance to hold the values that can
68 * be exported
69 *
70 * @var array
71 */
72 static $_export = NULL;
73 /**
74 * static value to see if we should log any modifications to
75 * this table in the civicrm_log table
76 *
77 * @var boolean
78 */
79 static $_log = TRUE;
80 /**
81 * Price Set Entity
82 *
83 * @var int unsigned
84 */
85 public $id;
86 /**
87 * Table which uses this price set
88 *
89 * @var string
90 */
91 public $entity_table;
92 /**
93 * Item in table
94 *
95 * @var int unsigned
96 */
97 public $entity_id;
98 /**
99 * price set being used
100 *
101 * @var int unsigned
102 */
103 public $price_set_id;
104
105 /**
106 * Class constructor.
107 *
108 * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity
109 */
110 public function __construct() {
111 $this->__table = 'civicrm_price_set_entity';
112 parent::__construct();
113 }
114
115 /**
116 * Return foreign links.
117 *
118 * @return array
119 */
120 public function links() {
121 if (!(self::$_links)) {
122 self::$_links = array(
123 'price_set_id' => 'civicrm_price_set:id',
124 );
125 }
126 return self::$_links;
127 }
128
129 /**
130 * Returns all the column names of this table.
131 *
132 * @return array
133 */
134 static function &fields() {
135 if (!(self::$_fields)) {
136 self::$_fields = array(
137 'id' => array(
138 'name' => 'id',
139 'type' => CRM_Utils_Type::T_INT,
140 'required' => TRUE,
141 ),
142 'entity_table' => array(
143 'name' => 'entity_table',
144 'type' => CRM_Utils_Type::T_STRING,
145 'title' => ts('Entity Table'),
146 'required' => TRUE,
147 'maxlength' => 64,
148 'size' => CRM_Utils_Type::BIG,
149 ),
150 'entity_id' => array(
151 'name' => 'entity_id',
152 'type' => CRM_Utils_Type::T_INT,
153 'required' => TRUE,
154 ),
155 'price_set_id' => array(
156 'name' => 'price_set_id',
157 'type' => CRM_Utils_Type::T_INT,
158 'required' => TRUE,
159 'FKClassName' => 'Snapshot_v4p2_Price_DAO_Set',
160 ),
161 );
162 }
163 return self::$_fields;
164 }
165
166 /**
167 * returns the names of this table.
168 *
169 * @return string
170 */
171 public static function getTableName() {
172 return self::$_tableName;
173 }
174
175 /**
176 * returns if this table needs to be logged.
177 *
178 * @return boolean
179 */
180 public function getLog() {
181 return self::$_log;
182 }
183
184 /**
185 * Returns the list of fields that can be imported.
186 *
187 * @param bool $prefix
188 *
189 * @return array
190 */
191 static function &import($prefix = FALSE) {
192 if (!(self::$_import)) {
193 self::$_import = array();
194 $fields = self::fields();
195 foreach ($fields as $name => $field) {
196 if (!empty($field['import'])) {
197 if ($prefix) {
198 self::$_import['price_set_entity'] = &$fields[$name];
199 }
200 else {
201 self::$_import[$name] = &$fields[$name];
202 }
203 }
204 }
205 }
206 return self::$_import;
207 }
208
209 /**
210 * returns the list of fields that can be exported.
211 *
212 * @param bool $prefix
213 *
214 * @return array
215 */
216 static function &export($prefix = FALSE) {
217 if (!(self::$_export)) {
218 self::$_export = array();
219 $fields = self::fields();
220 foreach ($fields as $name => $field) {
221 if (!empty($field['export'])) {
222 if ($prefix) {
223 self::$_export['price_set_entity'] = &$fields[$name];
224 }
225 else {
226 self::$_export[$name] = &$fields[$name];
227 }
228 }
229 }
230 }
231 return self::$_export;
232 }
233 }