break; case 'MOVE': $f_project_id = gpc_get_int('project_id'); if (access_has_bug_level(config_get('move_bug_threshold'), $t_bug_id) && access_has_project_level(config_get('report_bug_threshold', null, null, $f_project_id), $f_project_id)) { # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); bug_move($t_bug_id, $f_project_id); helper_call_custom_function('issue_update_notify', array($t_bug_id)); } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access'); } break; case 'COPY': $f_project_id = gpc_get_int('project_id'); if (access_has_project_level(config_get('report_bug_threshold'), $f_project_id)) { # Copy everything except history bug_copy($t_bug_id, $f_project_id, true, true, false, true, true, true); } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access'); } break; case 'ASSIGN': $f_assign = gpc_get_int('assign'); if (ON == config_get('auto_set_status_to_assigned')) { $t_assign_status = config_get('bug_assigned_status'); } else { $t_assign_status = $t_status; } # check that new handler has rights to handle the issue, and # that current user has rights to assign the issue $t_threshold = access_get_status_threshold($t_assign_status, $t_bug->project_id); if (access_has_bug_level(config_get('update_bug_assign_threshold', config_get('update_bug_threshold')), $t_bug_id)) {
function copyUserStory($us_id, $status, $sprintname) { global $agilemantis_pb; global $agilemantis_tasks; global $agilemantis_sprint; $new_bug_id = bug_copy($us_id, null, true, true, false, true, true, true); $agilemantis_pb->doUserStoryToSprint($new_bug_id, $sprintname); relationship_add($new_bug_id, $us_id, 0); $task = $agilemantis_sprint->getSprintTasks($us_id); $agilemantis_sprint->sprint_id = $sprintname; $sprintinfo = $agilemantis_sprint->getSprintById(); $old_userstory = $agilemantis_pb->checkForUserStory($us_id); $agilemantis_pb->addStoryPoints($new_bug_id, $old_userstory['storypoints']); $agilemantis_pb->addBusinessValue($new_bug_id, $old_userstory['businessValue']); $agilemantis_pb->addRankingOrder($new_bug_id, $old_userstory['rankingorder']); $agilemantis_pb->addTechnical($new_bug_id, $old_userstory['technical']); $agilemantis_pb->addPresentable($new_bug_id, $old_userstory['presentable']); $agilemantis_pb->AddInReleaseDocu($new_bug_id, $old_userstory['inReleaseDocu']); $agilemantis_pb->AddPlannedWork($new_bug_id, $old_userstory['plannedWork']); history_delete($new_bug_id); $bugnote_text_new = plugin_lang_get('divide_userstories_from') . $agilemantis_pb->getUserName(auth_get_current_user_id()) . plugin_lang_get('divide_userstories_of') . ' #' . $us_id . plugin_lang_get('divide_userstories_splitted'); $bugnote_text_old = plugin_lang_get('divide_userstories_from') . $agilemantis_pb->getUserName(auth_get_current_user_id()) . plugin_lang_get('divide_userstories_from') . ', #' . $new_bug_id . plugin_lang_get('divide_userstories_splitted'); $agilemantis_sprint->sprint_id = $old_userstory['sprint']; $sprintinfo = $agilemantis_sprint->getSprintById(); $userstory_performed = false; $wmu = 0; $spmu = 0; if (!empty($task)) { foreach ($task as $key => $value) { if ($value['performed_capacity'] > 0 || $value['status'] >= 4) { $userstory_performed = true; } if ($value['status'] < 4) { $agilemantis_tasks->user_id = auth_get_current_user_id(); $agilemantis_tasks->name = $value['name']; $agilemantis_tasks->us_id = $value['us_id']; $agilemantis_tasks->description = $value['description']; $agilemantis_tasks->developer = $value['developer_id']; $agilemantis_tasks->status = 5; $agilemantis_tasks->capacity = $value['performed_capacity']; $agilemantis_tasks->planned_capacity = $value['planned_capacity']; $agilemantis_tasks->rest_capacity = 0; $agilemantis_tasks->id = $value['id']; $agilemantis_tasks->unit = $value['unit']; $agilemantis_tasks->editTask(); $agilemantis_tasks->saveDailyPerformance(0); $agilemantis_tasks->id = 0; $agilemantis_tasks->name = $value['name']; $agilemantis_tasks->us_id = $new_bug_id; $agilemantis_tasks->description = $value['description']; $agilemantis_tasks->status = $value['status']; if ($value['status'] == 3) { $agilemantis_tasks->status = 2; } $agilemantis_tasks->developer = $value['developer_id']; if ($agilemantis_sprint->getUnitId(plugin_config_get('gadiv_task_unit_mode')) != $sprintinfo['unit_planned_task']) { $agilemantis_tasks->planned_capacity = 0; $agilemantis_tasks->rest_capacity = 0; } else { $agilemantis_tasks->planned_capacity = $value['rest_capacity']; $agilemantis_tasks->rest_capacity = $value['rest_capacity']; } $agilemantis_tasks->addFinishedNote($value['us_id'], $value['id'], auth_get_current_user_id()); $agilemantis_tasks->editTask(); $agilemantis_tasks->id = 0; $agilemantis_tasks->updateTaskLog($value['id'], auth_get_current_user_id(), "closed"); $agilemantis_tasks->setTaskStatus($value['id'], 5); $wmu += $value['rest_capacity']; $new_storypoints += $value['performed_capacity']; } } } if ($sprintinfo['unit_planned_task'] == 3) { $spmu = $wmu; } else { $spmu = 0; } # collect all user story splitting information and write these into database $agilemantis_sprint->setSplittingInformation($us_id, $new_bug_id, $wmu, $spmu); if ($userstory_performed === true) { if ($sprintinfo['unit_planned_task'] < 3) { $agilemantis_pb->addStoryPoints($new_bug_id, ''); } elseif ($sprintinfo['unit_planned_task'] == 3) { $agilemantis_pb->addStoryPoints($new_bug_id, $old_userstory['storypoints'] - $new_storypoints); } $bugnote_text_new .= plugin_lang_get('divide_userstories_old_estimation') . " #" . $us_id . plugin_lang_get('divide_userstories_with') . $old_userstory['storypoints'] . " SP."; bugnote_add($new_bug_id, $bugnote_text_new); } # add bug note bugnote_add($us_id, $bugnote_text_old); $agilemantis_tasks->setUserStoryStatus($us_id, $status, auth_get_current_user_id()); $agilemantis_tasks->closeUserStory($us_id, $status, auth_get_current_user_id()); bug_update_date($us_id); }