+
+ return true;
+ }
+
+ // getReportOptions - returns an array of report options constructed from session bean.
+ //
+ // Note: similarly to ttFavReportHelper::getReportOptions, this function is a part of
+ // refactoring to simplify maintenance of report generating functions, as we currently
+ // have 2 sets: normal reporting (from bean), and fav report emailing (from db fields).
+ // Using options obtained from either db or bean shall allow us to use only one set of functions.
+ static function getReportOptions($bean) {
+ global $user;
+
+ // Prepare an array of report options.
+ $options = array();
+
+ // Construct one by one.
+ $options['name'] = null; // No name required.
+ $options['user_id'] = $user->id; // Not sure if we need user_id here. Fav reports use it to recycle $user object in cron.php.
+ $options['client_id'] = $bean->getAttribute('client');
+ $options['cf_1_option_id'] = $bean->getAttribute('option');
+ $options['project_id'] = $bean->getAttribute('project');
+ $options['task_id'] = $bean->getAttribute('task');
+ $options['billable'] = $bean->getAttribute('include_records');
+ $options['invoice'] = $bean->getAttribute('invoice');
+ $options['paid_status'] = $bean->getAttribute('paid_status');
+ if (is_array($bean->getAttribute('users'))) $options['users'] = join(',', $bean->getAttribute('users'));
+ $options['period'] = $bean->getAttribute('period');
+ $options['period_start'] = $bean->getAttribute('start_date');
+ $options['period_end'] = $bean->getAttribute('end_date');
+ $options['show_client'] = $bean->getAttribute('chclient');
+ $options['show_invoice'] = $bean->getAttribute('chinvoice');
+ $options['show_paid'] = $bean->getAttribute('chpaid');
+ $options['show_ip'] = $bean->getAttribute('chip');
+ $options['show_project'] = $bean->getAttribute('chproject');
+ $options['show_start'] = $bean->getAttribute('chstart');
+ $options['show_duration'] = $bean->getAttribute('chduration');
+ $options['show_cost'] = $bean->getAttribute('chcost');
+ $options['show_task'] = $bean->getAttribute('chtask');
+ $options['show_end'] = $bean->getAttribute('chfinish');
+ $options['show_note'] = $bean->getAttribute('chnote');
+ $options['show_custom_field_1'] = $bean->getAttribute('chcf_1');
+ $options['show_work_units'] = $bean->getAttribute('chunits');
+ $options['show_totals_only'] = $bean->getAttribute('chtotalsonly');
+ $options['group_by'] = $bean->getAttribute('group_by');
+ return $options;
+ }
+
+ // verifyBean is a security function to make sure data in bean makes sense for a group.
+ static function verifyBean($bean) {
+ global $user;
+
+ // Check users.
+ $users_in_bean = $bean->getAttribute('users');
+ if (is_array($users_in_bean)) {
+ $users_in_group = ttTeamHelper::getUsers();
+ foreach ($users_in_group as $user_in_group) {
+ $valid_ids[] = $user_in_group['id'];
+ }
+ foreach ($users_in_bean as $user_in_bean) {
+ if (!in_array($user_in_bean, $valid_ids)) {
+ return false;
+ }
+ }
+ }
+
+ // TODO: add additional checks here. Perhaps do it before saving the bean for consistency.