xml/templates/dao.tpl - Centralize export() / import() logic
[civicrm-core.git] / CRM / Core / DAO / Mapping.php
CommitLineData
e501603b
TO
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 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Core/Mapping.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:4e293e6d117828f1e2000de5a4a0d0c0)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_mapping';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = false;
83 /**
84 * Mapping ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * Name of Mapping
91 *
92 * @var string
93 */
94 public $name;
95 /**
96 * Description of Mapping.
97 *
98 * @var string
99 */
100 public $description;
101 /**
102 * Mapping Type
103 *
104 * @var int unsigned
105 */
106 public $mapping_type_id;
107 /**
108 * class constructor
109 *
110 * @return civicrm_mapping
111 */
112 function __construct() {
113 $this->__table = 'civicrm_mapping';
114 parent::__construct();
115 }
116 /**
117 * Returns all the column names of this table
118 *
119 * @return array
120 */
121 static function &fields() {
122 if (!(self::$_fields)) {
123 self::$_fields = array(
124 'id' => array(
125 'name' => 'id',
126 'type' => CRM_Utils_Type::T_INT,
127 'title' => ts('Mapping ID') ,
128 'description' => 'Mapping ID',
129 'required' => true,
130 ) ,
131 'name' => array(
132 'name' => 'name',
133 'type' => CRM_Utils_Type::T_STRING,
134 'title' => ts('Name') ,
135 'description' => 'Name of Mapping',
136 'maxlength' => 64,
137 'size' => CRM_Utils_Type::BIG,
138 ) ,
139 'description' => array(
140 'name' => 'description',
141 'type' => CRM_Utils_Type::T_STRING,
142 'title' => ts('Description') ,
143 'description' => 'Description of Mapping.',
144 'maxlength' => 255,
145 'size' => CRM_Utils_Type::HUGE,
146 ) ,
147 'mapping_type_id' => array(
148 'name' => 'mapping_type_id',
149 'type' => CRM_Utils_Type::T_INT,
150 'title' => ts('Mapping Type') ,
151 'description' => 'Mapping Type',
152 'html' => array(
153 'type' => 'Select',
154 ) ,
155 'pseudoconstant' => array(
156 'optionGroupName' => 'mapping_type',
157 'optionEditPath' => 'civicrm/admin/options/mapping_type',
158 )
159 ) ,
160 );
161 }
162 return self::$_fields;
163 }
164 /**
165 * Returns an array containing, for each field, the arary key used for that
166 * field in self::$_fields.
167 *
168 * @return array
169 */
170 static function &fieldKeys() {
171 if (!(self::$_fieldKeys)) {
172 self::$_fieldKeys = array(
173 'id' => 'id',
174 'name' => 'name',
175 'description' => 'description',
176 'mapping_type_id' => 'mapping_type_id',
177 );
178 }
179 return self::$_fieldKeys;
180 }
181 /**
182 * Returns the names of this table
183 *
184 * @return string
185 */
186 static function getTableName() {
187 return self::$_tableName;
188 }
189 /**
190 * Returns if this table needs to be logged
191 *
192 * @return boolean
193 */
194 function getLog() {
195 return self::$_log;
196 }
197 /**
198 * Returns the list of fields that can be imported
199 *
200 * @param bool $prefix
201 *
202 * @return array
203 */
204 static function &import($prefix = false) {
205 if (!(self::$_import)) {
206 self::$_import = array();
207 $fields = self::fields();
208 foreach($fields as $name => $field) {
209 if (CRM_Utils_Array::value('import', $field)) {
210 if ($prefix) {
211 self::$_import['mapping'] = & $fields[$name];
212 } else {
213 self::$_import[$name] = & $fields[$name];
214 }
215 }
216 }
217 }
218 return self::$_import;
219 }
220 /**
221 * Returns the list of fields that can be exported
222 *
223 * @param bool $prefix
224 *
225 * @return array
226 */
227 static function &export($prefix = false) {
228 if (!(self::$_export)) {
229 self::$_export = array();
230 $fields = self::fields();
231 foreach($fields as $name => $field) {
232 if (CRM_Utils_Array::value('export', $field)) {
233 if ($prefix) {
234 self::$_export['mapping'] = & $fields[$name];
235 } else {
236 self::$_export[$name] = & $fields[$name];
237 }
238 }
239 }
240 }
241 return self::$_export;
242 }
243}