diff --git a/classes/manager/step_manager.php b/classes/manager/step_manager.php index fa36c92d85f5b97cd3f10d94b9767c9f20ec05e8..a2332f746b292d4f71e8f32dd9a9332225ddaee5 100644 --- a/classes/manager/step_manager.php +++ b/classes/manager/step_manager.php @@ -175,7 +175,6 @@ class step_manager extends subplugin_manager { * @return array of step instances. */ public static function get_step_instances($workflowid) { - // TODO: Alter calls to include workflow id. global $DB; $records = $DB->get_records('tool_lifecycle_step', array( 'workflowid' => $workflowid diff --git a/step/email/interactionlib.php b/step/email/interactionlib.php index 1c1ae76cd96a7be1f60d818e13f05dfb13b7c603..e6e96ec5ea3f652827db061691a9516202049dc2 100644 --- a/step/email/interactionlib.php +++ b/step/email/interactionlib.php @@ -100,9 +100,21 @@ class interactionemail extends interactionlibbase { * @return null */ public function get_due_date($processid, $stepid) { - $settings = settings_manager::get_settings($stepid, settings_type::STEP); $process = process_manager::get_process_by_id($processid); - $date = $settings['responsetimeout'] + $process->timestepchanged; + $steps = step_manager::get_step_instances($process->workflowid); + // Necessary to access steps through counting variable. + $steps = array_values($steps); + // Keep track of the delays for future email steps and sum them up. + $date = $process->timestepchanged; + for ($i = $process->stepindex; $i <= count($steps); $i++) { + // The variable $i represents the stepindex. The index of $steps starts at 0. + /* @var $step step_subplugin class entry of the subplugin step */ + $step = $steps[$i - 1]; + if ($step->subpluginname == 'email') { + $settings = settings_manager::get_settings($step->id, settings_type::STEP); + $date += $settings['responsetimeout']; + } + } // TODO default format -- seconds -> not in this class ! return date('d.m.Y', $date); }