Merge pull request #10115 from jmcclelland/CRM-20388
[civicrm-core.git] / CRM / Core / DAO / Note.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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-2017
30 *
31 * Generated from xml/schema/CRM/Core/Note.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:9f5e4f2a7e73840743efc268ffb4dbfd)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Core_DAO_Note constructor.
39 */
40 class CRM_Core_DAO_Note extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_note';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Note ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Name of table where item being referenced is stored.
61 *
62 * @var string
63 */
64 public $entity_table;
65 /**
66 * Foreign key to the referenced item.
67 *
68 * @var int unsigned
69 */
70 public $entity_id;
71 /**
72 * Note and/or Comment.
73 *
74 * @var text
75 */
76 public $note;
77 /**
78 * FK to Contact ID creator
79 *
80 * @var int unsigned
81 */
82 public $contact_id;
83 /**
84 * When was this note last modified/edited
85 *
86 * @var date
87 */
88 public $modified_date;
89 /**
90 * subject of note description
91 *
92 * @var string
93 */
94 public $subject;
95 /**
96 * Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)
97 *
98 * @var string
99 */
100 public $privacy;
101 /**
102 * Class constructor.
103 */
104 function __construct() {
105 $this->__table = 'civicrm_note';
106 parent::__construct();
107 }
108 /**
109 * Returns foreign keys and entity references.
110 *
111 * @return array
112 * [CRM_Core_Reference_Interface]
113 */
114 static function getReferenceColumns() {
115 if (!isset(Civi::$statics[__CLASS__]['links'])) {
116 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
117 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
118 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
119 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
120 }
121 return Civi::$statics[__CLASS__]['links'];
122 }
123 /**
124 * Returns all the column names of this table
125 *
126 * @return array
127 */
128 static function &fields() {
129 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
130 Civi::$statics[__CLASS__]['fields'] = array(
131 'id' => array(
132 'name' => 'id',
133 'type' => CRM_Utils_Type::T_INT,
134 'title' => ts('Note ID') ,
135 'description' => 'Note ID',
136 'required' => true,
137 'table_name' => 'civicrm_note',
138 'entity' => 'Note',
139 'bao' => 'CRM_Core_BAO_Note',
140 'localizable' => 0,
141 ) ,
142 'entity_table' => array(
143 'name' => 'entity_table',
144 'type' => CRM_Utils_Type::T_STRING,
145 'title' => ts('Note Entity') ,
146 'description' => 'Name of table where item being referenced is stored.',
147 'required' => true,
148 'maxlength' => 64,
149 'size' => CRM_Utils_Type::BIG,
150 'table_name' => 'civicrm_note',
151 'entity' => 'Note',
152 'bao' => 'CRM_Core_BAO_Note',
153 'localizable' => 0,
154 'pseudoconstant' => array(
155 'callback' => 'CRM_Core_BAO_Note::entityTables',
156 )
157 ) ,
158 'entity_id' => array(
159 'name' => 'entity_id',
160 'type' => CRM_Utils_Type::T_INT,
161 'title' => ts('Note Entity ID') ,
162 'description' => 'Foreign key to the referenced item.',
163 'required' => true,
164 'table_name' => 'civicrm_note',
165 'entity' => 'Note',
166 'bao' => 'CRM_Core_BAO_Note',
167 'localizable' => 0,
168 ) ,
169 'note' => array(
170 'name' => 'note',
171 'type' => CRM_Utils_Type::T_TEXT,
172 'title' => ts('Note') ,
173 'description' => 'Note and/or Comment.',
174 'rows' => 4,
175 'cols' => 60,
176 'import' => true,
177 'where' => 'civicrm_note.note',
178 'headerPattern' => '/Note|Comment/i',
179 'dataPattern' => '//',
180 'export' => true,
181 'table_name' => 'civicrm_note',
182 'entity' => 'Note',
183 'bao' => 'CRM_Core_BAO_Note',
184 'localizable' => 0,
185 'html' => array(
186 'type' => 'TextArea',
187 ) ,
188 ) ,
189 'contact_id' => array(
190 'name' => 'contact_id',
191 'type' => CRM_Utils_Type::T_INT,
192 'title' => ts('Note Created By') ,
193 'description' => 'FK to Contact ID creator',
194 'table_name' => 'civicrm_note',
195 'entity' => 'Note',
196 'bao' => 'CRM_Core_BAO_Note',
197 'localizable' => 0,
198 'FKClassName' => 'CRM_Contact_DAO_Contact',
199 ) ,
200 'modified_date' => array(
201 'name' => 'modified_date',
202 'type' => CRM_Utils_Type::T_DATE,
203 'title' => ts('Note Modified By') ,
204 'description' => 'When was this note last modified/edited',
205 'table_name' => 'civicrm_note',
206 'entity' => 'Note',
207 'bao' => 'CRM_Core_BAO_Note',
208 'localizable' => 0,
209 ) ,
210 'subject' => array(
211 'name' => 'subject',
212 'type' => CRM_Utils_Type::T_STRING,
213 'title' => ts('Subject') ,
214 'description' => 'subject of note description',
215 'maxlength' => 255,
216 'size' => 60,
217 'table_name' => 'civicrm_note',
218 'entity' => 'Note',
219 'bao' => 'CRM_Core_BAO_Note',
220 'localizable' => 0,
221 'html' => array(
222 'type' => 'Text',
223 ) ,
224 ) ,
225 'privacy' => array(
226 'name' => 'privacy',
227 'type' => CRM_Utils_Type::T_STRING,
228 'title' => ts('Privacy') ,
229 'description' => 'Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)',
230 'maxlength' => 255,
231 'size' => CRM_Utils_Type::HUGE,
232 'table_name' => 'civicrm_note',
233 'entity' => 'Note',
234 'bao' => 'CRM_Core_BAO_Note',
235 'localizable' => 0,
236 'pseudoconstant' => array(
237 'optionGroupName' => 'note_privacy',
238 'optionEditPath' => 'civicrm/admin/options/note_privacy',
239 )
240 ) ,
241 );
242 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
243 }
244 return Civi::$statics[__CLASS__]['fields'];
245 }
246 /**
247 * Return a mapping from field-name to the corresponding key (as used in fields()).
248 *
249 * @return array
250 * Array(string $name => string $uniqueName).
251 */
252 static function &fieldKeys() {
253 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
254 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
255 }
256 return Civi::$statics[__CLASS__]['fieldKeys'];
257 }
258 /**
259 * Returns the names of this table
260 *
261 * @return string
262 */
263 static function getTableName() {
264 return self::$_tableName;
265 }
266 /**
267 * Returns if this table needs to be logged
268 *
269 * @return boolean
270 */
271 function getLog() {
272 return self::$_log;
273 }
274 /**
275 * Returns the list of fields that can be imported
276 *
277 * @param bool $prefix
278 *
279 * @return array
280 */
281 static function &import($prefix = false) {
282 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'note', $prefix, array());
283 return $r;
284 }
285 /**
286 * Returns the list of fields that can be exported
287 *
288 * @param bool $prefix
289 *
290 * @return array
291 */
292 static function &export($prefix = false) {
293 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'note', $prefix, array());
294 return $r;
295 }
296 /**
297 * Returns the list of indices
298 */
299 public static function indices($localize = TRUE) {
300 $indices = array(
301 'index_entity' => array(
302 'name' => 'index_entity',
303 'field' => array(
304 0 => 'entity_table',
305 1 => 'entity_id',
306 ) ,
307 'localizable' => false,
308 'sig' => 'civicrm_note::0::entity_table::entity_id',
309 ) ,
310 );
311 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
312 }
313 }