public function processLevelAndBadgeValidation() { $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); $ids_badge = Badge::getIdsBadgesToValidate(); 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; } $badge->validated = 1; $return &= $badge->save(); $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; }