false) $Result = true; } return $Result; } function GetXPFromTranslation($UserId) { global $System, $xp_from_word, $from_diakrit, $Config; $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree(); $xp = 0; foreach ($TranslationTree as $Group) { if ($Group['TablePrefix'] != '') { $GroupBy = 'GROUP BY '; $TakeColumns = ''; foreach ($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) { $GroupBy .= '`T`.`'.$TextItem['Column'].'`, '; $TakeColumns .= ', `T2`.`'.$TextItem['Column'].'` AS `'.$TextItem['Column'].'_Take`'; } $GroupBy = substr($GroupBy, 0, -2); $IDtran = $System->Database->query('SELECT *, `T2`.`Language` AS `Language_Take`'.$TakeColumns.' FROM `'.$Group['TablePrefix'].'` AS `T` '. 'LEFT JOIN `'.$Group['TablePrefix'].'` AS `T2` ON `T2`.`ID` = `T`.`Take` '. 'WHERE (`T`.`User` = '.$UserId.') AND (`T`.`Complete` = 1) AND (`T`.`Take` IS NOT NULL) '.$GroupBy); while ($Line = $IDtran->fetch_array()) { $xp_translation = 0; $translated = true; foreach ($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) { if (($Line[$TextItem['Column']] <> $Line[$TextItem['Column'].'_Take']) and (strlen($Line[$TextItem['Column']]) > (strlen($Line[$TextItem['Column'].'_Take']) * 0.5))) { $TextArr = explode(' ', $Line[$TextItem['Column']]); foreach ($TextArr as $Word) { if (CheckDiakrit($Word)) $indikator = $from_diakrit; else $indikator = 1; $xp_translation = $xp_translation + ($indikator * $xp_from_word); } } else { if (($Line[$TextItem['Column']] == $Line[$TextItem['Column'].'_Take']) and ($Config['OriginalLanguage'] == $Line['Language_Take']) and ($Line[$TextItem['Column'].'_Take'] <> '') and ($TextItem['Column'] <> 'ShortCut')) $translated = false; } } if ($translated) $xp = $xp + $xp_translation; // XP addition for entire translation if complete translated } } } return $xp; } function UserLevelUpdate($UserId) { global $System, $Config; $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree(); // Main code for users $DbResult = $System->Database->query('SELECT `ID`, `Name` FROM `User` WHERE `Id` = '.$UserId); if ($DbResult->num_rows > 0) { while ($LineUser = $DbResult->fetch_array()) { // Build TranslatedCount query $TranslatedCount = '('; if (count($TranslationTree) > 0) { foreach ($TranslationTree as $Group) if ($Group['TablePrefix'] != '') { $Count = '(SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND (`Language` <> '. $Config['OriginalLanguage'].') AND (`User`='.$LineUser['ID'].'))'; $TranslatedCount .= 'COALESCE('.$Count.', 0) + '; } $TranslatedCount = substr($TranslatedCount, 0, -3).')'; } else $TranslatedCount = 0; $xp = GetXPFromTranslation($LineUser['ID']); $System->Database->query('UPDATE `User` SET `XP` = '.$xp.', `TranslatedCount` = '.$TranslatedCount.' WHERE `User`.`ID` = '.$LineUser['ID']); } } }