/** * Handle on_copy_project_items event * * @param Project $from * @param Project $to * @param array $milestones_map * @param array $categories_map * @return null */ function tickets_handle_on_copy_project_items(&$from, &$to, $milestones_map, $categories_map) { $tickets = Tickets::findByProject($from, null, STATE_VISIBLE, VISIBILITY_PRIVATE); if (is_foreachable($tickets)) { foreach ($tickets as $ticket) { $ticket->copyToProject($to, array_var($milestones_map, $ticket->getMilestoneId()), array_var($categories_map, $ticket->getParentId()), array('Task', 'Attachment')); } // foreach } // if }
/** * Export tickets * * @param void * @return null */ function export() { $object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL); $exportable_modules = explode(',', array_var($_GET, 'modules', null)); if (!is_foreachable($exportable_modules)) { $exportable_modules = null; } // if require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php'; $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules); if (!$output_builder->createOutputFolder()) { $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); } // if $output_builder->createAttachmentsFolder(); $module_categories = Categories::findByModuleSection($this->active_project, $this->active_module, $this->active_module); $module_objects = Tickets::findByProject($this->active_project, null, STATE_VISIBLE, $object_visibility); $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'index'); $output_builder->smarty->assign('categories', $module_categories); $output_builder->smarty->assign('objects', $module_objects); $output_builder->outputToFile('index'); // export tickets by categories if (is_foreachable($module_categories)) { foreach ($module_categories as $module_category) { if (instance_of($module_category, 'Category')) { $output_builder->smarty->assign(array('current_category' => $module_category, 'objects' => Tickets::findByProject($this->active_project, $module_category, STATE_VISIBLE, $object_visibility))); $output_builder->outputToFile('category_' . $module_category->getId()); } // if } // foreach } // if // export tickets if (is_foreachable($module_objects)) { $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'object'); foreach ($module_objects as $module_object) { if (instance_of($module_object, 'Ticket')) { $output_builder->outputAttachments($module_object->getAttachments()); $comments = $module_object->getComments($object_visibility); $output_builder->outputObjectsAttachments($comments); if (module_loaded('timetracking')) { $timerecords = TimeRecords::findByParent($module_object, null, STATE_VISIBLE, $object_visibility); $total_time = TimeRecords::calculateTime($timerecords); } else { $timerecords = null; $total_time = 0; } // if $output_builder->smarty->assign(array('timerecords' => $timerecords, 'total_time' => $total_time, 'object' => $module_object, 'comments' => $comments)); $output_builder->outputToFile('ticket_' . $module_object->getId()); } // if } // foreach } // if $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); }