File: 0.01.1a/config/DD.php (View as HTML)

  1: <?php 
  2: /* -------------------------------------------------------------
  3: This file is part of FreeDESK
  4: 
  5: FreeDESK is (C) Copyright 2012 David Cutting
  6: 
  7: FreeDESK is free software: you can redistribute it and/or modify
  8: it under the terms of the GNU General Public License as published by
  9: the Free Software Foundation, either version 3 of the License, or
 10: (at your option) any later version.
 11: 
 12: FreeDESK is distributed in the hope that it will be useful,
 13: but WITHOUT ANY WARRANTY; without even the implied warranty of
 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15: GNU General Public License for more details.
 16: 
 17: You should have received a copy of the GNU General Public License
 18: along with FreeDESK.  If not, see www.gnu.org/licenses
 19: 
 20: For more information see www.purplepixie.org/freedesk/
 21: -------------------------------------------------------------- */
 22: 
 23: // NOTE: DO NOT EDIT THIS FILE DIRECTLY FOR CUSTOMISATIONS!
 24: // RATHER USE A PLUGIN MODULE OR OTHER USER-SCRIPT TO ADD DD
 25: // DATA!
 26: 
 27: // Of course you are free to change this file - this is open-source
 28: // after all but if you do not only will it be overwritten but you
 29: // could well break your install... You have been warned!
 30: 
 31: /**
 32:  * FreeDESK Main Core Data Dictionary Definitions - do not edit as will be overwritten on upgrade
 33: **/
 34: class FreeDESK_DD
 35: {
 36: /**
 37:  * Static exec function will setup the core data dictionary
 38:  * @param mixed $DESK Instance of FreeDESK
 39: **/
 40: static function Exec(&$DESK)
 41: {
 42: 	// System Log (syslog)
 43: 	
 44: 	$syslog = new DD_Table();
 45: 	$syslog->name = "SysLog";
 46: 	$syslog->entity = "syslog";
 47: 	$syslog->editable = true;
 48: 	
 49: 	$event_id = new DD_Field();
 50: 	$event_id->name = "Event ID";
 51: 	$event_id->field = "event_id";
 52: 	$event_id->type = DD_FieldType::Int;
 53: 	$event_id->searchable = true;
 54: 	$event_id->keyfield = true;
 55: 	$event_id->display = true;
 56: 	$syslog->Add($event_id);
 57: 	
 58: 	$event_dt = new DD_Field();
 59: 	$event_dt->name = "Event DateTime";
 60: 	$event_dt->field = "event_dt";
 61: 	$event_dt->type = DD_FieldType::DateTime;
 62: 	$event_dt->searchable = true;
 63: 	$event_dt->display = true;
 64: 	$syslog->Add($event_dt);
 65: 	
 66: 	$event = new DD_Field();
 67: 	$event->name="Event";
 68: 	$event->field="event";
 69: 	$event->type=DD_FieldType::Char;
 70: 	$event->size=254;
 71: 	$event->searchable = true;
 72: 	$event->display = true;
 73: 	$syslog->Add($event);
 74: 	
 75: 	$event_class = new DD_Field();
 76: 	$event_class->name="Event Class";
 77: 	$event_class->field="event_class";
 78: 	$event_class->type=DD_FieldType::Char;
 79: 	$event_class->size=128;
 80: 	$event_class->searchable = true;
 81: 	$event_class->display = true;
 82: 	$syslog->Add($event_class);
 83: 	
 84: 	$event_type = new DD_Field();
 85: 	$event_type->name="Event Type";
 86: 	$event_type->field="event_type";
 87: 	$event_type->type=DD_FieldType::Char;
 88: 	$event_type->size=128;
 89: 	$event_type->searchable = true;
 90: 	$event_type->display = true;
 91: 	$syslog->Add($event_type);
 92: 	
 93: 	$event_level = new DD_Field();
 94: 	$event_level->name="Event Level";
 95: 	$event_level->field="event_level";
 96: 	$event_level->type=DD_FieldType::Int;
 97: 	$event_level->searchable = true;
 98: 	$event_level->display = true;
 99: 	$syslog->Add($event_level);
100: 	
101: 	$DESK->DataDictionary->AddTable($syslog);
102: 	
103: 	// System Configuration (sysconfig)
104: 	
105: 	$sysconfig = new DD_Table();
106: 	$sysconfig->name="SysConfig";
107: 	$sysconfig->entity="sysconfig";
108: 	
109: 	$sc_option = new DD_Field();
110: 	$sc_option->name="SC Option";
111: 	$sc_option->field="sc_option";
112: 	$sc_option->type=DD_FieldType::Char;
113: 	$sc_option->size=254;
114: 	$sc_option->searchable=true;
115: 	$sc_option->display=true;
116: 	$sysconfig->Add($sc_option);
117: 	
118: 	$sc_value = new DD_Field();
119: 	$sc_value->name="SC Value";
120: 	$sc_value->field="sc_value";
121: 	$sc_value->type=DD_FieldType::Char;
122: 	$sc_value->size=254;
123: 	$sc_value->searchable=true;
124: 	$sc_value->display=true;
125: 	$sysconfig->Add($sc_value);
126: 	
127: 	$DESK->DataDictionary->AddTable($sysconfig);
128: 	
129: 	// User Data
130: 	$user = new DD_Table();
131: 	$user->name="Users";
132: 	$user->entity="user";
133: 	
134: 	$f = new DD_Field();
135: 	$f->name="Username";
136: 	$f->field="username";
137: 	$f->type=DD_FieldType::Char;
138: 	$f->size=254;
139: 	$f->searchable=true;
140: 	$f->display=true;
141: 	$f->keyfield=true;
142: 	$user->Add($f);
143: 	
144: 	$f = new DD_Field();
145: 	$f->name="Password";
146: 	$f->field="password";
147: 	$f->type=DD_FieldType::Char;
148: 	$f->size=254;
149: 	$f->searchable=false;
150: 	$f->display=false;
151: 	$user->Add($f);
152: 	
153: 	$f = new DD_Field();
154: 	$f->name="Real Name";
155: 	$f->field="realname";
156: 	$f->type=DD_FieldType::Char;
157: 	$f->size=254;
158: 	$f->searchable=true;
159: 	$f->display=true;
160: 	$user->Add($f);
161: 	
162: 	$f = new DD_Field();
163: 	$f->name="Email";
164: 	$f->field="email";
165: 	$f->type=DD_FieldType::Char;
166: 	$f->size=254;
167: 	$f->searchable=true;
168: 	$f->display=true;
169: 	$user->Add($f);
170: 	
171: 	$f = new DD_Field();
172: 	$f->name="Auth Type";
173: 	$f->field="authtype";
174: 	$f->type=DD_FieldType::Char;
175: 	$f->size=254;
176: 	$f->searchable=false;
177: 	$f->display=false;
178: 	$user->Add($f);
179: 	
180: 	for ($i=0; $i<10; ++$i)
181: 	{
182: 		$f = new DD_Field();
183: 		$f->name="Spare Field ".$i;
184: 		$f->field="sparefield".$i;
185: 		$f->type=DD_FieldType::Char;
186: 		$f->size=254;
187: 		$f->searchable=true;
188: 		$f->display=true;
189: 		$user->Add($f);
190: 	}
191: 	
192: 	$DESK->DataDictionary->AddTable($user);
193: 	
194: 	// Session
195: 	$session = new DD_Table();
196: 	$session->name="Session";
197: 	$session->entity="session";
198: 	
199: 	$f = new DD_Field();
200: 	$f->name="Session ID";
201: 	$f->field="session_id";
202: 	$f->type=DD_FieldType::Char;
203: 	$f->size=254;
204: 	$f->keyfield=true;
205: 	$f->seachable=true;
206: 	$f->display=true;
207: 	$session->Add($f);
208: 	
209: 	$f = new DD_Field();
210: 	$f->name="Username";
211: 	$f->field="username";
212: 	$f->type=DD_FieldType::Char;
213: 	$f->size=254;
214: 	$f->searchable=true;
215: 	$f->display=true;
216: 	$f->foreignkey=true; 		// n.b. also FK for customer but user just linked internally
217: 	$f->foreignentity="user"; 	// not that it matters as this isn't handled through entity model
218: 	$f->foreignfield="username";// but will create OTM link as a DD_Relationship
219: 	$session->Add($f);
220: 	
221: 	$f = new DD_Field();
222: 	$f->name="Session Type";
223: 	$f->field="sessiontype";
224: 	$f->type=DD_FieldType::Int;
225: 	$f->searchable=false;
226: 	$f->display=false;
227: 	$session->Add($f);
228: 	
229: 	$f = new DD_Field();
230: 	$f->name="Created DateTime";
231: 	$f->field="created_dt";
232: 	$f->type=DD_FieldType::DateTime;
233: 	$f->searchable=true;
234: 	$f->display=true;
235: 	$session->Add($f);
236: 	
237: 	$f = new DD_Field();
238: 	$f->name="Updated DateTime";
239: 	$f->field="updated_dt";
240: 	$f->type=DD_FieldType::DateTime;
241: 	$f->searchable=true;
242: 	$f->display=true;
243: 	$session->Add($f);
244: 	
245: 	$f = new DD_Field();
246: 	$f->name="Expires DateTime";
247: 	$f->field="expires_dt";
248: 	$f->type=DD_FieldType::DateTime;
249: 	$f->searchable=true;
250: 	$f->display=true;
251: 	$session->Add($f);
252: 	
253: 	$DESK->DataDictionary->AddTable($session);
254: 	
255: 	$sessionuser = new DD_Relationship();
256: 	$sessionuser->type=DD_RelationshipType::OTM;
257: 	$sessionuser->firstentity = "user";
258: 	$sessionuser->firstfield = "username";
259: 	$sessionuser->secondentity = "session";
260: 	$sessionuser->secondfield = "username";
261: 	
262: 	$DESK->DataDictionary->AddRelationship($sessionuser);
263: 	
264: 	// Customer
265: 	
266: 	$customer = new DD_Table();
267: 	$customer->name="Customer";
268: 	$customer->entity="customer";
269: 	$customer->editable=true;
270: 	
271: 	$f = new DD_Field();
272: 	$f->name="Customer ID";
273: 	$f->field="customerid";
274: 	$f->type=DD_FieldType::Int;
275: 	$f->searchable=true;
276: 	$f->readonly=true;
277: 	$f->display=true;
278: 	$f->keyfield=true;
279: 	$customer->Add($f);
280: 	
281: 	$f = new DD_Field();
282: 	$f->name="First Name";
283: 	$f->field="firstname";
284: 	$f->type=DD_FieldType::Char;
285: 	$f->size=254;
286: 	$f->searchable=true;
287: 	$f->display=true;
288: 	$customer->Add($f);
289: 	
290: 	$f = new DD_Field();
291: 	$f->name="Last Name";
292: 	$f->field="lastname";
293: 	$f->type=DD_FieldType::Char;
294: 	$f->size=254;
295: 	$f->searchable=true;
296: 	$f->display=true;
297: 	$customer->Add($f);
298: 	
299: 	$f = new DD_Field();
300: 	$f->name="Email";
301: 	$f->field="email";
302: 	$f->type=DD_FieldType::Char;
303: 	$f->size=254;
304: 	$f->searchable=true;
305: 	$f->display=true;
306: 	$customer->Add($f);
307: 	
308: 	$f = new DD_Field();
309: 	$f->name="Username";
310: 	$f->field="username";
311: 	$f->type=DD_FieldType::Char;
312: 	$f->size=254;
313: 	$f->searchable=true;
314: 	$f->display=true;
315: 	$customer->Add($f);
316: 	
317: 	$f = new DD_Field();
318: 	$f->name="Password";
319: 	$f->field="password";
320: 	$f->type=DD_FieldType::Password;
321: 	$f->size=254;
322: 	$f->searchable=false;
323: 	$f->display=false;
324: 	$customer->Add($f);
325: 	
326: 	$DESK->DataDictionary->AddTable($customer);
327: }
328: 
329: }
330: 
331: ?>
332: