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 // TODO: big data sets get us out of memory error.
339 // We need to optimize this by working on smaller result sets at a time.
340 // tt_log is one potentially large table, but so may be others.
341 // Refactor this during next round of work here.
342 $records = $this->getRecordsFromTable('tt_log');
343 if (count($records) > 0) {
344 fwrite($this->file, $this->indentation." <log>\n");
346 foreach ($records as $record) {
348 $this->logMap[$record['id']] = $key;
349 $log_part = $this->indentation.' '."<log_item id=\"$key\"";
350 $log_part .= " user_id=\"".$this->userMap[$record['user_id']]."\"";
351 $log_part .= " date=\"".$record['date']."\"";
352 $log_part .= " start=\"".$record['start']."\"";
353 $log_part .= " duration=\"".$record['duration']."\"";
354 $log_part .= " client_id=\"".$this->clientMap[$record['client_id']]."\"";
355 $log_part .= " project_id=\"".$this->projectMap[$record['project_id']]."\"";
356 $log_part .= " task_id=\"".$this->taskMap[$record['task_id']]."\"";
357 $log_part .= " invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\"";
358 $log_part .= " comment=\"".htmlspecialchars($record['comment'])."\"";
359 $log_part .= " billable=\"".$record['billable']."\"";
360 $log_part .= " paid=\"".$record['paid']."\"";
361 $log_part .= " status=\"".$record['status']."\"";
362 $log_part .= "></log_item>\n";
363 fwrite($this->file, $log_part);
365 fwrite($this->file, $this->indentation." </log>\n");
370 // Write custom fields.
371 if (count($custom_fields) > 0) {
372 fwrite($this->file, $this->indentation." <custom_fields>\n");
373 foreach ($custom_fields as $custom_field) {
374 $custom_field_part = $this->indentation.' '."<custom_field id=\"".$this->customFieldMap[$custom_field['id']]."\"";
375 $custom_field_part .= " type=\"".$custom_field['type']."\"";
376 $custom_field_part .= " label=\"".htmlspecialchars($custom_field['label'])."\"";
377 $custom_field_part .= " required=\"".$custom_field['required']."\"";
378 $custom_field_part .= " status=\"".$custom_field['status']."\"";
379 $custom_field_part .= "></custom_field>\n";
380 fwrite($this->file, $custom_field_part);
382 fwrite($this->file, $this->indentation." </custom_fields>\n");
383 unset($custom_fields);
384 unset($custom_field_part);
387 // Write custom field options.
388 if (count($custom_field_options) > 0) {
389 fwrite($this->file, $this->indentation." <custom_field_options>\n");
390 foreach ($custom_field_options as $option) {
391 $custom_field_option_part = $this->indentation.' '."<custom_field_option id=\"".$this->customFieldOptionMap[$option['id']]."\"";
392 $custom_field_option_part .= " field_id=\"".$this->customFieldMap[$option['field_id']]."\"";
393 $custom_field_option_part .= " value=\"".htmlspecialchars($option['value'])."\"";
394 $custom_field_option_part .= "></custom_field_option>\n";
395 fwrite($this->file, $custom_field_option_part);
397 fwrite($this->file, $this->indentation." </custom_field_options>\n");
398 unset($custom_field_options);
399 unset($custom_field_option_part);
402 // Write custom field log.
403 $custom_field_log = ttTeamHelper::getCustomFieldLog($this->group_id);
404 if (count($custom_field_log) > 0) {
405 fwrite($this->file, $this->indentation." <custom_field_log>\n");
406 foreach ($custom_field_log as $entry) {
407 $custom_field_log_part = $this->indentation.' '."<custom_field_log_entry log_id=\"".$this->logMap[$entry['log_id']]."\"";
408 $custom_field_log_part .= " field_id=\"".$this->customFieldMap[$entry['field_id']]."\"";
409 $custom_field_log_part .= " option_id=\"".$this->customFieldOptionMap[$entry['option_id']]."\"";
410 $custom_field_log_part .= " value=\"".htmlspecialchars($entry['value'])."\"";
411 $custom_field_log_part .= " status=\"".$entry['status']."\"";
412 $custom_field_log_part .= "></custom_field_log_entry>\n";
413 fwrite($this->file, $custom_field_log_part);
415 fwrite($this->file, $this->indentation." </custom_field_log>\n");
416 unset($custom_field_log);
417 unset($custom_field_log_part);
420 // Write expense items.
421 $expense_items = ttTeamHelper::getExpenseItems($this->group_id);
422 if (count($expense_items) > 0) {
423 fwrite($this->file, $this->indentation." <expense_items>\n");
424 foreach ($expense_items as $expense_item) {
425 $expense_item_part = $this->indentation.' '."<expense_item date=\"".$expense_item['date']."\"";
426 $expense_item_part .= " user_id=\"".$this->userMap[$expense_item['user_id']]."\"";
427 $expense_item_part .= " client_id=\"".$this->clientMap[$expense_item['client_id']]."\"";
428 $expense_item_part .= " project_id=\"".$this->projectMap[$expense_item['project_id']]."\"";
429 $expense_item_part .= " name=\"".htmlspecialchars($expense_item['name'])."\"";
430 $expense_item_part .= " cost=\"".$expense_item['cost']."\"";
431 $expense_item_part .= " invoice_id=\"".$this->invoiceMap[$expense_item['invoice_id']]."\"";
432 $expense_item_part .= " paid=\"".$expense_item['paid']."\"";
433 $expense_item_part .= " status=\"".$expense_item['status']."\"";
434 $expense_item_part .= "></expense_item>\n";
435 fwrite($this->file, $expense_item_part);
437 fwrite($this->file, $this->indentation." </expense_items>\n");
438 unset($expense_items);
439 unset($expense_item_part);
442 // Write predefined expenses.
443 $predefined_expenses = $this->getRecordsFromTable('tt_predefined_expenses');
444 if (count($predefined_expenses) > 0) {
445 fwrite($this->file, $this->indentation." <predefined_expenses>\n");
446 foreach ($predefined_expenses as $predefined_expense) {
447 $predefined_expense_part = $this->indentation.' '."<predefined_expense name=\"".htmlspecialchars($predefined_expense['name'])."\"";
448 $predefined_expense_part .= " cost=\"".$predefined_expense['cost']."\"";
449 $predefined_expense_part .= "></predefined_expense>\n";
450 fwrite($this->file, $predefined_expense_part);
452 fwrite($this->file, $this->indentation." </predefined_expenses>\n");
453 unset($predefined_expenses);
454 unset($predefined_expense_part);
457 // Write monthly quotas.
458 $quotas = ttTeamHelper::getMonthlyQuotas($this->group_id);
459 if (count($quotas) > 0) {
460 fwrite($this->file, $this->indentation." <monthly_quotas>\n");
461 foreach ($quotas as $quota) {
462 $quota_part = $this->indentation.' '."<monthly_quota year=\"".$quota['year']."\"";
463 $quota_part .= " month=\"".$quota['month']."\"";
464 $quota_part .= " minutes=\"".$quota['minutes']."\"";
465 $quota_part .= "></monthly_quota>\n";
466 fwrite($this->file, $quota_part);
468 fwrite($this->file, $this->indentation." </monthly_quotas>\n");
473 // Write fav reports.
474 if (count($fav_reports) > 0) {
475 fwrite($this->file, $this->indentation." <fav_reports>\n");
476 foreach ($fav_reports as $fav_report) {
478 if (strlen($fav_report['users']) > 0) {
479 $arr = explode(',', $fav_report['users']);
480 foreach ($arr as $k=>$v) {
481 if (array_key_exists($arr[$k], $this->userMap))
482 $user_list .= (strlen($user_list) == 0? '' : ',').$this->userMap[$v];
485 $fav_report_part = $this->indentation.' '."<fav_report id=\"".$this->favReportMap[$fav_report['id']]."\"";
486 $fav_report_part .= " user_id=\"".$this->userMap[$fav_report['user_id']]."\"";
487 $fav_report_part .= " name=\"".htmlspecialchars($fav_report['name'])."\"";
488 $fav_report_part .= " client_id=\"".$this->clientMap[$fav_report['client_id']]."\"";
489 $fav_report_part .= " cf_1_option_id=\"".$this->customFieldOptionMap[$fav_report['cf_1_option_id']]."\"";
490 $fav_report_part .= " project_id=\"".$this->projectMap[$fav_report['project_id']]."\"";
491 $fav_report_part .= " task_id=\"".$this->taskMap[$fav_report['task_id']]."\"";
492 $fav_report_part .= " billable=\"".$fav_report['billable']."\"";
493 $fav_report_part .= " users=\"".$user_list."\"";
494 $fav_report_part .= " period=\"".$fav_report['period']."\"";
495 $fav_report_part .= " period_start=\"".$fav_report['period_start']."\"";
496 $fav_report_part .= " period_end=\"".$fav_report['period_end']."\"";
497 $fav_report_part .= " show_client=\"".$fav_report['show_client']."\"";
498 $fav_report_part .= " show_invoice=\"".$fav_report['show_invoice']."\"";
499 $fav_report_part .= " show_paid=\"".$fav_report['show_paid']."\"";
500 $fav_report_part .= " show_ip=\"".$fav_report['show_ip']."\"";
501 $fav_report_part .= " show_project=\"".$fav_report['show_project']."\"";
502 $fav_report_part .= " show_start=\"".$fav_report['show_start']."\"";
503 $fav_report_part .= " show_duration=\"".$fav_report['show_duration']."\"";
504 $fav_report_part .= " show_cost=\"".$fav_report['show_cost']."\"";
505 $fav_report_part .= " show_task=\"".$fav_report['show_task']."\"";
506 $fav_report_part .= " show_end=\"".$fav_report['show_end']."\"";
507 $fav_report_part .= " show_note=\"".$fav_report['show_note']."\"";
508 $fav_report_part .= " show_custom_field_1=\"".$fav_report['show_custom_field_1']."\"";
509 $fav_report_part .= " show_work_units=\"".$fav_report['show_work_units']."\"";
510 $fav_report_part .= " group_by1=\"".$fav_report['group_by1']."\"";
511 $fav_report_part .= " group_by2=\"".$fav_report['group_by2']."\"";
512 $fav_report_part .= " group_by3=\"".$fav_report['group_by3']."\"";
513 $fav_report_part .= " show_totals_only=\"".$fav_report['show_totals_only']."\"";
514 $fav_report_part .= "></fav_report>\n";
515 fwrite($this->file, $fav_report_part);
517 fwrite($this->file, $this->indentation." </fav_reports>\n");
519 unset($fav_report_part);
522 // Write notifications.
523 $notifications = $this->getRecordsFromTable('tt_cron');
524 if (count($notifications) > 0) {
525 fwrite($this->file, $this->indentation." <notifications>\n");
526 foreach ($notifications as $notification) {
527 $notification_part = $this->indentation.' '."<notification cron_spec=\"".$notification['cron_spec']."\"";
528 $notification_part .= " last=\"".$notification['last']."\"";
529 $notification_part .= " next=\"".$notification['next']."\"";
530 $notification_part .= " report_id=\"".$this->favReportMap[$notification['report_id']]."\"";
531 $notification_part .= " email=\"".htmlspecialchars($notification['email'])."\"";
532 $notification_part .= " cc=\"".htmlspecialchars($notification['cc'])."\"";
533 $notification_part .= " subject=\"".htmlspecialchars($notification['subject'])."\"";
534 $notification_part .= " report_condition=\"".htmlspecialchars($notification['report_condition'])."\"";
535 $notification_part .= " status=\"".$notification['status']."\"";
536 $notification_part .= "></notification>\n";
537 fwrite($this->file, $notification_part);
539 fwrite($this->file, $this->indentation." </notifications>\n");
540 unset($notifications);
541 unset($notification_part);
544 // Write user config parameters.
545 $user_params = $this->getRecordsFromTable('tt_config');
546 if (count($user_params) > 0) {
547 fwrite($this->file, $this->indentation." <user_params>\n");
548 foreach ($user_params as $user_param) {
549 $user_param_part = $this->indentation.' '."<user_param user_id=\"".$this->userMap[$user_param['user_id']]."\"";
550 $user_param_part .= " param_name=\"".htmlspecialchars($user_param['param_name'])."\"";
551 $user_param_part .= " param_value=\"".htmlspecialchars($user_param['param_value'])."\"";
552 $user_param_part .= "></user_param>\n";
553 fwrite($this->file, $user_param_part);
555 fwrite($this->file, $this->indentation." </user_params>\n");
557 unset($user_param_part);
560 // We are mostly done with writing this group data, destroy all maps.
561 unset($this->roleMap);
562 unset($this->userMap);
563 unset($this->taskMap);
564 unset($this->projectMap);
565 unset($this->clientMap);
566 unset($this->invoiceMap);
567 unset($this->logMap);
568 unset($this->customFieldMap);
569 unset($this->customFieldOptionMap);
571 // Call self recursively for all subgroups.
572 foreach ($this->subgroups as $subgroup) {
573 $subgroup_helper = new ttGroupExportHelper($subgroup['id'], $this->file, $this->indentation.' ');
574 $subgroup_helper->writeData();
576 unset($this->subgroups);
578 fwrite($this->file, $this->indentation."</group>\n");