function postProcess($class, &$form, $gid, $term) { $excare = CRM_Utils_Request::retrieve('excare', 'Integer', $form, false, null, $_REQUEST); if ($excare != 1) { return; } $childID = $form->getVar('_id'); if (empty($childID) || !CRM_Utils_Rule::positiveInteger($childID)) { return; } $params = $form->controller->exportValues($form->getVar('_name')); $daysOfWeek =& self::daysOfWeek(); $sessions =& self::sessions(); $classSignedUpFor = array(); $classCancelled = array(); foreach ($daysOfWeek as $day) { foreach ($sessions as $session) { $name = "sfschool_activity_{$day}_{$session}"; if (!empty($params["{$name}_cancel"])) { if (!array_key_exists($day, $classCancelled)) { $classCancelled[$day] = array(); } $classCancelled[$day][$session] = $params[$name]; continue; } if (!in_array($name, self::$_registeredElements) && !empty($params[$name])) { if (!array_key_exists($day, $classSignedUpFor)) { $classSignedUpFor[$day] = array(); } $classSignedUpFor[$day][$session] = $params[$name]; } } } if (empty($classSignedUpFor) && empty($classCancelled)) { return; } require_once 'SFS/Utils/Query.php'; $grade = SFS_Utils_Query::getGrade($childID); if (!is_numeric($grade)) { return; } $classInfo = self::getClassCount($grade, false, $term); self::getCurrentClasses($childID, $classInfo, $term); $activities = self::getActivities($grade, $classInfo, true, $term); $templateVars = array('term' => $term, 'classCancelled' => array(), 'classSignedUpFor' => array()); // first deal with all cancelled classes if (!empty($classCancelled)) { foreach ($classCancelled as $day => $dayValues) { foreach ($dayValues as $session => $classID) { if (array_key_exists($classID, $activities[$day][$session]['details'])) { self::postProcessClass($childID, $activities[$day][$session]['details'][$classID], 'Cancelled'); $templateVars['classCancelled'][$classID] = $activities[$day][$session]['details'][$classID]; } else { CRM_Core_Error::fatal($classID); } } } } if (!empty($classSignedUpFor)) { foreach ($classSignedUpFor as $day => $dayValues) { foreach ($dayValues as $session => $classID) { if (array_key_exists($classID, $activities[$day][$session]['details'])) { self::postProcessClass($childID, $activities[$day][$session]['details'][$classID], 'Added'); $templateVars['classSignedUpFor'][$classID] = $activities[$day][$session]['details'][$classID]; } else { CRM_Core_Error::fatal($classID); } } } } self::sendExtendedCareEmail($childID, $templateVars); }