public function processLevelAndBadgeValidation($ids_badge) { $return = true; $current_level = (int) Configuration::get('GF_CURRENT_LEVEL'); $current_level_percent = (int) Configuration::get('GF_CURRENT_LEVEL_PERCENT'); $not_viewed_badge = explode('|', ltrim(Configuration::get('GF_NOT_VIEWED_BADGE', ''), '')); $nbr_notif = Configuration::get('GF_NOTIFICATION', 0); if (count($ids_badge)) { $not_viewed_badge = array(); } //reset the last badge only if there is new badge to validate foreach ($ids_badge as $id) { $badge = new Badge((int) $id); if ($badge->scoring + $current_level_percent >= 100) { $current_level++; $current_level_percent = $badge->scoring + $current_level_percent - 100; } else { $current_level_percent += $badge->scoring; } $return &= $badge->validate(); $condition_ids = Condition::getIdsByBadgeGroup($badge->id_group); if (is_array($condition_ids) && count($condition_ids)) { foreach ($condition_ids as $id) { $cond = new Condition((int) $id); $cond->processCalculation(); unset($cond); } $new_ids_badge = Badge::getIdsBadgesToValidate(); $this->processLevelAndBadgeValidation($new_ids_badge); } $nbr_notif++; $not_viewed_badge[] = $badge->id; } Configuration::updateGlobalValue('GF_NOTIFICATION', (int) $nbr_notif); Configuration::updateGlobalValue('GF_NOT_VIEWED_BADGE', implode('|', array_unique($not_viewed_badge))); Configuration::updateGlobalValue('GF_CURRENT_LEVEL', (int) $current_level); Configuration::updateGlobalValue('GF_CURRENT_LEVEL_PERCENT', (int) $current_level_percent); return $return; }