Changeset 350 for trunk/img_level.php
- Timestamp:
- Mar 3, 2010, 12:50:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/img_level.php
r349 r350 103 103 function ImgLevelUpdate() 104 104 { 105 global $Database ;105 global $Database, $TranslationTree; 106 106 107 107 // Hlavní kod pro uživatele 108 $ID = $Database->SQLCommand('SELECT ID,user FROM user WHERE NeedUpdate= 1');108 $ID = $Database->SQLCommand('SELECT `ID`, `user` FROM `user` WHERE `NeedUpdate` = 1'); 109 109 while($LineUser = mysql_fetch_array($ID)) 110 110 { 111 $xp = GetXPFromTranslation($LineUser['ID']); // Načítání XP 112 $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']); // Ukládání XP pro řazení 113 CreateImg('user', $LineUser['user'], $xp); // Vytváření obrázku 111 // Build TranslatedCount query 112 $TranslatedCount = '('; 113 foreach($TranslationTree as $Group) 114 if($Group['TablePrefix'] != '') 115 { 116 $Count = '(SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND (`Language` <> 0) AND (`User`='.$LineUser['ID'].'))'; 117 $TranslatedCount .= 'COALESCE('.$Count.', 0) + '; 118 } 119 $TranslatedCount = substr($TranslatedCount, 0, -3).')'; 120 121 $xp = GetXPFromTranslation($LineUser['ID']); 122 $Database->SQLCommand('UPDATE `user` SET `XP` = '.$xp.', `TranslatedCount` = '.$TranslatedCount.' WHERE `user`.`ID` = '.$LineUser['ID']); 123 CreateImg('user', $LineUser['user'], $xp); 114 124 } 115 125 116 126 // Hlavní kod pro překladatelské týmy 117 $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = Team.Id) as average FROM Team WHERE ID IN (SELECT Team FROM user WHERE NeedUpdate= 1)');127 $ID = $Database->SQLCommand('SELECT `ID`, `name`, (SELECT AVG(`XP`) FROM `user` WHERE `team` = `Team`.`Id`) AS `average` FROM `Team` WHERE `ID` IN (SELECT `Team` FROM `user` WHERE `NeedUpdate` = 1)'); 118 128 while($LineTeam = mysql_fetch_array($ID)) 119 129 { 120 130 CreateImg('team', $LineTeam['name'], substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.'))); //vytváření obrázku 121 131 } 122 $Database->SQLCommand('UPDATE user SET NeedUpdate= 0');132 $Database->SQLCommand('UPDATE `user` SET `NeedUpdate` = 0'); 123 133 } 124 134 … … 127 137 global $Database; 128 138 129 // Hlavní kod pro uživatele 130 $ID = $Database->SQLCommand('SELECT ID,user FROM user'); 139 // Do update for all users 140 $Database->SQLCommand('UPDATE `user` SET `NeedUpdate` = 1'); 141 ImgLevelUpdate(); 142 143 echo('<strong>Uživatelé</strong><br/>'); 144 $ID = $Database->SQLCommand('SELECT `ID`, `user` FROM `user`'); 131 145 while($LineUser = mysql_fetch_array($ID)) 132 146 { 133 $xp = GetXPFromTranslation($LineUser['ID']); // Načítání XP 134 $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']); // Ukládání XP pro řazení 135 CreateImg('user', $LineUser['user'], $xp); // Vytváření obrázku 136 echo('<img src="tmp/user/'.$LineUser['user'].'/level.png" /><br />'); 147 echo('<img src="tmp/user/'.$LineUser['user'].'/level.png" /> '.$LineUser['user'].'<br />'); 137 148 } 138 149 139 // Hlavní kod pro překladatelské týmy140 $ID = $Database->SQLCommand('SELECT ID, name,(SELECT avg(XP) FROM user WHERE team = Team.Id) as average FROM Team');150 echo('<br/><strong>Týmy</strong><br/>'); 151 $ID = $Database->SQLCommand('SELECT ID, Name FROM Team'); 141 152 while($LineTeam = mysql_fetch_array($ID)) 142 153 { 143 CreateImg('team', $LineTeam['name'], substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.'))); // Vytváření obrázku 144 echo('<img src="tmp/team/'.$LineTeam['name'].'/level.png" /><br />'); 154 echo('<img src="tmp/team/'.$LineTeam['Name'].'/level.png" /> '.$LineTeam['Name'].'<br />'); 145 155 } 146 $Database->SQLCommand('UPDATE user SET NeedUpdate = 0');147 156 } 148 157
Note:
See TracChangeset
for help on using the changeset viewer.