2 // +----------------------------------------------------------------------+
3 // | Anuko Time Tracker
4 // +----------------------------------------------------------------------+
5 // | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6 // +----------------------------------------------------------------------+
7 // | LIBERAL FREEWARE LICENSE: This source code document may be used
8 // | by anyone for any purpose, and freely redistributed alone or in
9 // | combination with other software, provided that the license is obeyed.
11 // | There are only two ways to violate the license:
13 // | 1. To redistribute this code in source form, with the copyright
14 // | notice or license removed or altered. (Distributing in compiled
15 // | forms without embedded copyright notices is permitted).
17 // | 2. To redistribute modified versions of this code in *any* form
18 // | that bears insufficient indications that the modifications are
19 // | not the work of the original author(s).
21 // | This license applies to this document only, not any other software
22 // | that it may be combined with.
24 // +----------------------------------------------------------------------+
26 // | https://www.anuko.com/time_tracker/credits.htm
27 // +----------------------------------------------------------------------+
29 // ttGroupExportHelper - this class is used to write data for a single group
30 // to a file. When group contains other groups, it reuses itself recursively.
31 class ttGroupExportHelper {
33 var $group_id = null; // Group we are exporting.
34 var $file = null; // File to write to.
35 var $indentation = null; // A string consisting of a number of spaces.
36 var $subgroups = array(); // Immediate subgroups.
38 // The following arrays are maps between entity ids in the file versus the database.
39 // We write to the file sequentially (1,2,3...) while in the database the entities have different ids.
40 var $userMap = array();
41 var $roleMap = array();
42 var $taskMap = array();
43 var $projectMap = array();
44 var $clientMap = array();
45 var $invoiceMap = array();
46 var $logMap = array();
47 var $customFieldMap = array();
48 var $customFieldOptionMap = array();
49 var $favReportMap = array();
52 function __construct($group_id, $file, $indentation) {
55 $this->group_id = $group_id;
57 $this->indentation = $indentation;
59 // Build a list of subgroups.
60 $mdb2 = getConnection();
61 $sql = "select id from tt_groups".
62 " where status = 1 and parent_id = $this->group_id and org_id = $user->org_id";
63 $res = $mdb2->query($sql);
64 if (!is_a($res, 'PEAR_Error')) {
65 while ($val = $res->fetchRow()) {
66 $this->subgroups[] = $val;
71 // getGroupAttrs obtains group attributes for export.
72 private function getGroupAttrs() {
74 $mdb2 = getConnection();
76 $sql = "select * from tt_groups".
77 " where status = 1 and id = $this->group_id and org_id = $user->org_id";
78 $res = $mdb2->query($sql);
79 if (!is_a($res, 'PEAR_Error')) {
80 $val = $res->fetchRow();
85 // The getUsers obtains all users in group for the purpose of export.
86 private function getUsers() {
88 $mdb2 = getConnection();
89 $sql = "select u.*, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id)".
90 " where u.group_id = $this->group_id and u.org_id = $user->org_id order by upper(u.name)"; // Note: deleted users are included.
91 $res = $mdb2->query($sql);
93 if (!is_a($res, 'PEAR_Error')) {
94 while ($val = $res->fetchRow()) {
102 // getRecordsFromTable - obtains all fields from a given table for a group.
103 function getRecordsFromTable($table_name) {
105 $mdb2 = getConnection();
108 $sql = "select * from $table_name where group_id = $this->group_id and org_id = $user->org_id";
109 $res = $mdb2->query($sql);
111 if (!is_a($res, 'PEAR_Error')) {
112 while ($val = $res->fetchRow()) {
120 // writeData writes group data into file.
121 function writeData() {
124 $group = $this->getGroupAttrs();
125 $group_part = "<group name=\"".htmlspecialchars($group['name'])."\"";
126 $group_part .= " description=\"".htmlspecialchars($group['description'])."\"";
127 $group_part .= " currency=\"".htmlspecialchars($group['currency'])."\"";
128 $group_part .= " decimal_mark=\"".$group['decimal_mark']."\"";
129 $group_part .= " lang=\"".$group['lang']."\"";
130 $group_part .= " date_format=\"".$group['date_format']."\"";
131 $group_part .= " time_format=\"".$group['time_format']."\"";
132 $group_part .= " week_start=\"".$group['week_start']."\"";
133 $group_part .= " tracking_mode=\"".$group['tracking_mode']."\"";
134 $group_part .= " project_required=\"".$group['project_required']."\"";
135 $group_part .= " task_required=\"".$group['task_required']."\"";
136 $group_part .= " record_type=\"".$group['record_type']."\"";
137 $group_part .= " bcc_email=\"".$group['bcc_email']."\"";
138 $group_part .= " allow_ip=\"".$group['allow_ip']."\"";
139 $group_part .= " password_complexity=\"".$group['password_complexity']."\"";
140 $group_part .= " plugins=\"".$group['plugins']."\"";
141 $group_part .= " lock_spec=\"".$group['lock_spec']."\"";
142 $group_part .= " workday_minutes=\"".$group['workday_minutes']."\"";
143 $group_part .= " custom_logo=\"".$group['custom_logo']."\"";
144 $group_part .= " config=\"".$group['config']."\"";
145 $group_part .= ">\n";
148 fwrite($this->file, $this->indentation.$group_part);
153 $users = $this->getUsers();
154 foreach ($users as $key=>$user_item)
155 $this->userMap[$user_item['id']] = $key + 1;
158 $roles = $this->getRecordsFromTable('tt_roles');
159 foreach ($roles as $key=>$role_item)
160 $this->roleMap[$role_item['id']] = $key + 1;
163 $tasks = $this->getRecordsFromTable('tt_tasks');
164 foreach ($tasks as $key=>$task_item)
165 $this->taskMap[$task_item['id']] = $key + 1;
167 // Prepare project map.
168 $projects = $this->getRecordsFromTable('tt_projects');
169 foreach ($projects as $key=>$project_item)
170 $this->projectMap[$project_item['id']] = $key + 1;
172 // Prepare client map.
173 $clients = $this->getRecordsFromTable('tt_clients');
174 foreach ($clients as $key=>$client_item)
175 $this->clientMap[$client_item['id']] = $key + 1;
177 // Prepare invoice map.
178 $invoices = ttTeamHelper::getAllInvoices();
179 foreach ($invoices as $key=>$invoice_item)
180 $this->invoiceMap[$invoice_item['id']] = $key + 1;
182 // Prepare custom fields map.
183 $custom_fields = ttTeamHelper::getAllCustomFields($this->group_id);
184 foreach ($custom_fields as $key=>$custom_field)
185 $this->customFieldMap[$custom_field['id']] = $key + 1;
187 // Prepare custom field options map.
188 $custom_field_options = ttTeamHelper::getAllCustomFieldOptions($this->group_id);
189 foreach ($custom_field_options as $key=>$option)
190 $this->customFieldOptionMap[$option['id']] = $key + 1;
192 // Prepare favorite report map.
193 $fav_reports = $this->getRecordsFromTable('tt_fav_reports');
194 foreach ($fav_reports as $key=>$fav_report)
195 $this->favReportMap[$fav_report['id']] = $key + 1;
198 fwrite($this->file, $this->indentation." <roles>\n");
199 foreach ($roles as $role) {
200 $role_part = $this->indentation.' '."<role id=\"".$this->roleMap[$role['id']]."\"";
201 $role_part .= " name=\"".htmlspecialchars($role['name'])."\"";
202 $role_part .= " description=\"".htmlspecialchars($role['description'])."\"";
203 $role_part .= " rank=\"".$role['rank']."\"";
204 $role_part .= " rights=\"".htmlspecialchars($role['rights'])."\"";
205 $role_part .= " status=\"".$role['status']."\"";
206 $role_part .= "></role>\n";
207 fwrite($this->file, $role_part);
209 fwrite($this->file, $this->indentation." </roles>\n");
214 if (count($tasks) > 0) {
215 fwrite($this->file, $this->indentation." <tasks>\n");
216 foreach ($tasks as $task) {
217 $task_part = $this->indentation.' '."<task id=\"".$this->taskMap[$task['id']]."\"";
218 $task_part .= " name=\"".htmlspecialchars($task['name'])."\"";
219 $task_part .= " description=\"".htmlspecialchars($task['description'])."\"";
220 $task_part .= " status=\"".$task['status']."\"";
221 $task_part .= "></task>\n";
222 fwrite($this->file, $task_part);
224 fwrite($this->file, $this->indentation." </tasks>\n");
230 if (count($projects) > 0) {
231 fwrite($this->file, $this->indentation." <projects>\n");
232 foreach ($projects as $project_item) {
234 if($project_item['tasks']){
235 $tasks = explode(',', $project_item['tasks']);
236 $tasks_mapped = array();
237 foreach ($tasks as $item)
238 $tasks_mapped[] = $this->taskMap[$item];
239 $tasks_str = implode(',', $tasks_mapped);
241 $project_part = $this->indentation.' '."<project id=\"".$this->projectMap[$project_item['id']]."\"";
242 $project_part .= " name=\"".htmlspecialchars($project_item['name'])."\"";
243 $project_part .= " description=\"".htmlspecialchars($project_item['description'])."\"";
244 $project_part .= " tasks=\"".$tasks_str."\"";
245 $project_part .= " status=\"".$project_item['status']."\"";
246 $project_part .= "></project>\n";
247 fwrite($this->file, $project_part);
249 fwrite($this->file, $this->indentation." </projects>\n");
251 unset($project_part);
255 if (count($clients) > 0) {
256 fwrite($this->file, $this->indentation." <clients>\n");
257 foreach ($clients as $client_item) {
258 if($client_item['projects']){
259 $projects_db = explode(',', $client_item['projects']);
260 $projects_mapped = array();
261 foreach ($projects_db as $item)
262 $projects_mapped[] = $this->projectMap[$item];
263 $projects_str = implode(',', $projects_mapped);
265 $client_part = $this->indentation.' '."<client id=\"".$this->clientMap[$client_item['id']]."\"";
266 $client_part .= " name=\"".htmlspecialchars($client_item['name'])."\"";
267 $client_part .= " address=\"".htmlspecialchars($client_item['address'])."\"";
268 $client_part .= " tax=\"".$client_item['tax']."\"";
269 $client_part .= " projects=\"".$projects_str."\"";
270 $client_part .= " status=\"".$client_item['status']."\"";
271 $client_part .= "></client>\n";
272 fwrite($this->file, $client_part);
274 fwrite($this->file, $this->indentation." </clients>\n");
280 if (count($users) > 0) {
281 fwrite($this->file, $this->indentation." <users>\n");
282 foreach ($users as $user_item) {
283 $role_id = $user_item['rank'] == 512 ? 0 : $this->roleMap[$user_item['role_id']]; // Special role_id 0 (not null) for top manager.
284 $user_part = $this->indentation.' '."<user id=\"".$this->userMap[$user_item['id']]."\"";
285 $user_part .= " name=\"".htmlspecialchars($user_item['name'])."\"";
286 $user_part .= " login=\"".htmlspecialchars($user_item['login'])."\"";
287 $user_part .= " password=\"".$user_item['password']."\"";
288 $user_part .= " role_id=\"".$role_id."\"";
289 $user_part .= " client_id=\"".$this->clientMap[$user_item['client_id']]."\"";
290 $user_part .= " rate=\"".$user_item['rate']."\"";
291 $user_part .= " email=\"".$user_item['email']."\"";
292 $user_part .= " status=\"".$user_item['status']."\"";
293 $user_part .= "></user>\n";
294 fwrite($this->file, $user_part);
296 fwrite($this->file, $this->indentation." </users>\n");
301 // Write user to project binds.
302 $user_binds = ttTeamHelper::getUserToProjectBinds($this->group_id);
303 if (count($user_binds) > 0) {
304 fwrite($this->file, $this->indentation." <user_project_binds>\n");
305 foreach ($user_binds as $bind) {
306 $user_id = $this->userMap[$bind['user_id']];
307 $project_id = $this->projectMap[$bind['project_id']];
308 $bind_part = $this->indentation.' '."<user_project_bind user_id=\"".$user_id."\"";
309 $bind_part .= " project_id=\"".$project_id."\"";
310 $bind_part .= " rate=\"".$bind['rate']."\"";
311 $bind_part .= " status=\"".$bind['status']."\"";
312 $bind_part .= "></user_project_bind>\n";
313 fwrite($this->file, $bind_part);
315 fwrite($this->file, $this->indentation." </user_project_binds>\n");
321 if (count($invoices) > 0) {
322 fwrite($this->file, $this->indentation." <invoices>\n");
323 foreach ($invoices as $invoice_item) {
324 $invoice_part = $this->indentation.' '."<invoice id=\"".$this->invoiceMap[$invoice_item['id']]."\"";
325 $invoice_part .= " name=\"".htmlspecialchars($invoice_item['name'])."\"";
326 $invoice_part .= " date=\"".$invoice_item['date']."\"";
327 $invoice_part .= " client_id=\"".$this->clientMap[$invoice_item['client_id']]."\"";
328 $invoice_part .= " status=\"".$invoice_item['status']."\"";
329 $invoice_part .= "></invoice>\n";
330 fwrite($this->file, $invoice_part);
332 fwrite($this->file, $this->indentation." </invoices>\n");
334 unset($invoice_part);
337 // Write time log entries and build logMap at the same time.
338 $records = $this->getRecordsFromTable('tt_log');
339 if (count($records) > 0) {
340 fwrite($this->file, $this->indentation." <log>\n");
342 foreach ($records as $record) {
344 $this->logMap[$record['id']] = $key;
345 $log_part = $this->indentation.' '."<log_item id=\"$key\"";
346 $log_part .= " user_id=\"".$this->userMap[$record['user_id']]."\"";
347 $log_part .= " date=\"".$record['date']."\"";
348 $log_part .= " start=\"".$record['start']."\"";
349 $log_part .= " duration=\"".$record['duration']."\"";
350 $log_part .= " client_id=\"".$this->clientMap[$record['client_id']]."\"";
351 $log_part .= " project_id=\"".$this->projectMap[$record['project_id']]."\"";
352 $log_part .= " task_id=\"".$this->taskMap[$record['task_id']]."\"";
353 $log_part .= " invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\"";
354 $log_part .= " comment=\"".htmlspecialchars($record['comment'])."\"";
355 $log_part .= " billable=\"".$record['billable']."\"";
356 $log_part .= " paid=\"".$record['paid']."\"";
357 $log_part .= " status=\"".$record['status']."\"";
358 $log_part .= "></log_item>\n";
359 fwrite($this->file, $log_part);
361 fwrite($this->file, $this->indentation." </log>\n");
366 // Write custom fields.
367 if (count($custom_fields) > 0) {
368 fwrite($this->file, $this->indentation." <custom_fields>\n");
369 foreach ($custom_fields as $custom_field) {
370 $custom_field_part = $this->indentation.' '."<custom_field id=\"".$this->customFieldMap[$custom_field['id']]."\"";
371 $custom_field_part .= " type=\"".$custom_field['type']."\"";
372 $custom_field_part .= " label=\"".htmlspecialchars($custom_field['label'])."\"";
373 $custom_field_part .= " required=\"".$custom_field['required']."\"";
374 $custom_field_part .= " status=\"".$custom_field['status']."\"";
375 $custom_field_part .= "></custom_field>\n";
376 fwrite($this->file, $custom_field_part);
378 fwrite($this->file, $this->indentation." </custom_fields>\n");
379 unset($custom_fields);
380 unset($custom_field_part);
383 // Write custom field options.
384 if (count($custom_field_options) > 0) {
385 fwrite($this->file, $this->indentation." <custom_field_options>\n");
386 foreach ($custom_field_options as $option) {
387 $custom_field_option_part = $this->indentation.' '."<custom_field_option id=\"".$this->customFieldOptionMap[$option['id']]."\"";
388 $custom_field_option_part .= " field_id=\"".$this->customFieldMap[$option['field_id']]."\"";
389 $custom_field_option_part .= " value=\"".htmlspecialchars($option['value'])."\"";
390 $custom_field_option_part .= "></custom_field_option>\n";
391 fwrite($this->file, $custom_field_option_part);
393 fwrite($this->file, $this->indentation." </custom_field_options>\n");
394 unset($custom_field_options);
395 unset($custom_field_option_part);
398 // Write custom field log.
399 $custom_field_log = ttTeamHelper::getCustomFieldLog($this->group_id);
400 if (count($custom_field_log) > 0) {
401 fwrite($this->file, $this->indentation." <custom_field_log>\n");
402 foreach ($custom_field_log as $entry) {
403 $custom_field_log_part = $this->indentation.' '."<custom_field_log_entry log_id=\"".$this->logMap[$entry['log_id']]."\"";
404 $custom_field_log_part .= " field_id=\"".$this->customFieldMap[$entry['field_id']]."\"";
405 $custom_field_log_part .= " option_id=\"".$this->customFieldOptionMap[$entry['option_id']]."\"";
406 $custom_field_log_part .= " value=\"".htmlspecialchars($entry['value'])."\"";
407 $custom_field_log_part .= " status=\"".$entry['status']."\"";
408 $custom_field_log_part .= "></custom_field_log_entry>\n";
409 fwrite($this->file, $custom_field_log_part);
411 fwrite($this->file, $this->indentation." </custom_field_log>\n");
412 unset($custom_field_log);
413 unset($custom_field_log_part);
416 // Write expense items.
417 $expense_items = ttTeamHelper::getExpenseItems($this->group_id);
418 if (count($expense_items) > 0) {
419 fwrite($this->file, $this->indentation." <expense_items>\n");
420 foreach ($expense_items as $expense_item) {
421 $expense_item_part = $this->indentation.' '."<expense_item date=\"".$expense_item['date']."\"";
422 $expense_item_part .= " user_id=\"".$this->userMap[$expense_item['user_id']]."\"";
423 $expense_item_part .= " client_id=\"".$this->clientMap[$expense_item['client_id']]."\"";
424 $expense_item_part .= " project_id=\"".$this->projectMap[$expense_item['project_id']]."\"";
425 $expense_item_part .= " name=\"".htmlspecialchars($expense_item['name'])."\"";
426 $expense_item_part .= " cost=\"".$expense_item['cost']."\"";
427 $expense_item_part .= " invoice_id=\"".$this->invoiceMap[$expense_item['invoice_id']]."\"";
428 $expense_item_part .= " paid=\"".$expense_item['paid']."\"";
429 $expense_item_part .= " status=\"".$expense_item['status']."\"";
430 $expense_item_part .= "></expense_item>\n";
431 fwrite($this->file, $expense_item_part);
433 fwrite($this->file, $this->indentation." </expense_items>\n");
434 unset($expense_items);
435 unset($expense_item_part);
438 // Write predefined expenses.
439 $predefined_expenses = $this->getRecordsFromTable('tt_predefined_expenses');
440 if (count($predefined_expenses) > 0) {
441 fwrite($this->file, $this->indentation." <predefined_expenses>\n");
442 foreach ($predefined_expenses as $predefined_expense) {
443 $predefined_expense_part = $this->indentation.' '."<predefined_expense name=\"".htmlspecialchars($predefined_expense['name'])."\"";
444 $predefined_expense_part .= " cost=\"".$predefined_expense['cost']."\"";
445 $predefined_expense_part .= "></predefined_expense>\n";
446 fwrite($this->file, $predefined_expense_part);
448 fwrite($this->file, $this->indentation." </predefined_expenses>\n");
449 unset($predefined_expenses);
450 unset($predefined_expense_part);
453 // Write monthly quotas.
454 $quotas = ttTeamHelper::getMonthlyQuotas($this->group_id);
455 if (count($quotas) > 0) {
456 fwrite($this->file, $this->indentation." <monthly_quotas>\n");
457 foreach ($quotas as $quota) {
458 $quota_part = $this->indentation.' '."<monthly_quota year=\"".$quota['year']."\"";
459 $quota_part .= " month=\"".$quota['month']."\"";
460 $quota_part .= " minutes=\"".$quota['minutes']."\"";
461 $quota_part .= "></monthly_quota>\n";
462 fwrite($this->file, $quota_part);
464 fwrite($this->file, $this->indentation." </monthly_quotas>\n");
469 // Write fav reports.
470 if (count($fav_reports) > 0) {
471 fwrite($this->file, $this->indentation." <fav_reports>\n");
472 foreach ($fav_reports as $fav_report) {
474 if (strlen($fav_report['users']) > 0) {
475 $arr = explode(',', $fav_report['users']);
476 foreach ($arr as $k=>$v) {
477 if (array_key_exists($arr[$k], $this->userMap))
478 $user_list .= (strlen($user_list) == 0? '' : ',').$this->userMap[$v];
481 $fav_report_part = $this->indentation.' '."<fav_report id=\"".$this->favReportMap[$fav_report['id']]."\"";
482 $fav_report_part .= " user_id=\"".$this->userMap[$fav_report['user_id']]."\"";
483 $fav_report_part .= " name=\"".htmlspecialchars($fav_report['name'])."\"";
484 $fav_report_part .= " client_id=\"".$this->clientMap[$fav_report['client_id']]."\"";
485 $fav_report_part .= " cf_1_option_id=\"".$this->customFieldOptionMap[$fav_report['cf_1_option_id']]."\"";
486 $fav_report_part .= " project_id=\"".$this->projectMap[$fav_report['project_id']]."\"";
487 $fav_report_part .= " task_id=\"".$this->taskMap[$fav_report['task_id']]."\"";
488 $fav_report_part .= " billable=\"".$fav_report['billable']."\"";
489 $fav_report_part .= " users=\"".$user_list."\"";
490 $fav_report_part .= " period=\"".$fav_report['period']."\"";
491 $fav_report_part .= " period_start=\"".$fav_report['period_start']."\"";
492 $fav_report_part .= " period_end=\"".$fav_report['period_end']."\"";
493 $fav_report_part .= " show_client=\"".$fav_report['show_client']."\"";
494 $fav_report_part .= " show_invoice=\"".$fav_report['show_invoice']."\"";
495 $fav_report_part .= " show_paid=\"".$fav_report['show_paid']."\"";
496 $fav_report_part .= " show_ip=\"".$fav_report['show_ip']."\"";
497 $fav_report_part .= " show_project=\"".$fav_report['show_project']."\"";
498 $fav_report_part .= " show_start=\"".$fav_report['show_start']."\"";
499 $fav_report_part .= " show_duration=\"".$fav_report['show_duration']."\"";
500 $fav_report_part .= " show_cost=\"".$fav_report['show_cost']."\"";
501 $fav_report_part .= " show_task=\"".$fav_report['show_task']."\"";
502 $fav_report_part .= " show_end=\"".$fav_report['show_end']."\"";
503 $fav_report_part .= " show_note=\"".$fav_report['show_note']."\"";
504 $fav_report_part .= " show_custom_field_1=\"".$fav_report['show_custom_field_1']."\"";
505 $fav_report_part .= " show_work_units=\"".$fav_report['show_work_units']."\"";
506 $fav_report_part .= " group_by1=\"".$fav_report['group_by1']."\"";
507 $fav_report_part .= " group_by2=\"".$fav_report['group_by2']."\"";
508 $fav_report_part .= " group_by3=\"".$fav_report['group_by3']."\"";
509 $fav_report_part .= " show_totals_only=\"".$fav_report['show_totals_only']."\"";
510 $fav_report_part .= "></fav_report>\n";
511 fwrite($this->file, $fav_report_part);
513 fwrite($this->file, $this->indentation." </fav_reports>\n");
515 unset($fav_report_part);
518 // Write notifications.
519 $notifications = $this->getRecordsFromTable('tt_cron');
520 if (count($notifications) > 0) {
521 fwrite($this->file, $this->indentation." <notifications>\n");
522 foreach ($notifications as $notification) {
523 $notification_part = $this->indentation.' '."<notification cron_spec=\"".$notification['cron_spec']."\"";
524 $notification_part .= " last=\"".$notification['last']."\"";
525 $notification_part .= " next=\"".$notification['next']."\"";
526 $notification_part .= " report_id=\"".$this->favReportMap[$notification['report_id']]."\"";
527 $notification_part .= " email=\"".htmlspecialchars($notification['email'])."\"";
528 $notification_part .= " cc=\"".htmlspecialchars($notification['cc'])."\"";
529 $notification_part .= " subject=\"".htmlspecialchars($notification['subject'])."\"";
530 $notification_part .= " report_condition=\"".htmlspecialchars($notification['report_condition'])."\"";
531 $notification_part .= " status=\"".$notification['status']."\"";
532 $notification_part .= "></notification>\n";
533 fwrite($this->file, $notification_part);
535 fwrite($this->file, $this->indentation." </notifications>\n");
536 unset($notifications);
537 unset($notification_part);
540 // Write user config parameters.
541 $user_params = $this->getRecordsFromTable('tt_config');
542 if (count($user_params) > 0) {
543 fwrite($this->file, $this->indentation." <user_params>\n");
544 foreach ($user_params as $user_param) {
545 $user_param_part = $this->indentation.' '."<user_param user_id=\"".$this->userMap[$user_param['user_id']]."\"";
546 $user_param_part .= " param_name=\"".htmlspecialchars($user_param['param_name'])."\"";
547 $user_param_part .= " param_value=\"".htmlspecialchars($user_param['param_value'])."\"";
548 $user_param_part .= "></user_param>\n";
549 fwrite($this->file, $user_param_part);
551 fwrite($this->file, $this->indentation." </user_params>\n");
553 unset($user_param_part);
556 // We are mostly done with writing this group data, destroy all maps.
557 unset($this->roleMap);
558 unset($this->userMap);
559 unset($this->taskMap);
560 unset($this->projectMap);
561 unset($this->clientMap);
562 unset($this->invoiceMap);
563 unset($this->logMap);
564 unset($this->customFieldMap);
565 unset($this->customFieldOptionMap);
567 // Call self recursively for all subgroups.
568 foreach ($this->subgroups as $subgroup) {
569 $subgroup_helper = new ttGroupExportHelper($subgroup['id'], $this->file, $this->indentation.' ');
570 $subgroup_helper->writeData();
572 unset($this->subgroups);
574 fwrite($this->file, $this->indentation."</group>\n");