Changeset 771


Ignore:
Timestamp:
Jan 31, 2014, 12:49:46 AM (11 years ago)
Author:
chronos
Message:
  • Modified: Do not execute UPDATE query on user list display.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/img_level.php

    r586 r771  
    107107  // Main code for users
    108108  $DbResult = $System->Database->query('SELECT `ID`, `Name` FROM `User` WHERE `NeedUpdate` = 1');
    109   while($LineUser = $DbResult->fetch_array())
     109  if($DbResult->num_rows > 0)
    110110  {
    111     // Build TranslatedCount query
    112     $TranslatedCount = '(';
    113     if(count($TranslationTree) > 0)
     111    while($LineUser = $DbResult->fetch_array())
    114112    {
    115           foreach($TranslationTree as $Group)
    116       if($Group['TablePrefix'] != '')
     113      // Build TranslatedCount query
     114      $TranslatedCount = '(';
     115      if(count($TranslationTree) > 0)
    117116      {
    118         $Count = '(SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND (`Language` <> '.
    119           $Config['OriginalLanguage'].') AND (`User`='.$LineUser['ID'].'))';
    120         $TranslatedCount .= 'COALESCE('.$Count.', 0) + ';
    121       }
    122       $TranslatedCount = substr($TranslatedCount, 0, -3).')';
    123     } else $TranslatedCount = 0;
     117            foreach($TranslationTree as $Group)
     118        if($Group['TablePrefix'] != '')
     119        {
     120          $Count = '(SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND (`Language` <> '.
     121            $Config['OriginalLanguage'].') AND (`User`='.$LineUser['ID'].'))';
     122          $TranslatedCount .= 'COALESCE('.$Count.', 0) + ';
     123        }
     124        $TranslatedCount = substr($TranslatedCount, 0, -3).')';
     125      } else $TranslatedCount = 0;
    124126   
    125     $xp = GetXPFromTranslation($LineUser['ID']);
    126     $System->Database->query('UPDATE `User` SET `XP` = '.$xp.', `TranslatedCount` = '.$TranslatedCount.' WHERE `User`.`ID` = '.$LineUser['ID']);
    127     CreateImg('user', $LineUser['Name'], $xp);
     127      $xp = GetXPFromTranslation($LineUser['ID']);
     128      $System->Database->query('UPDATE `User` SET `XP` = '.$xp.', `TranslatedCount` = '.$TranslatedCount.' WHERE `User`.`ID` = '.$LineUser['ID']);
     129      CreateImg('user', $LineUser['Name'], $xp);
     130    }
     131
     132    // Main code for translation teams
     133    $DbResult = $System->Database->query('SELECT `ID`, `Name`, (SELECT AVG(`XP`) FROM `User` WHERE `Team` = `Team`.`Id`) AS `Average` '.
     134      'FROM `Team` WHERE `ID` IN (SELECT `Team` FROM `User` WHERE `NeedUpdate` = 1)');
     135    while($LineTeam = $DbResult->fetch_array())
     136    {
     137      CreateImg('team', $LineTeam['Name'], substr($LineTeam['Average'], 0, strpos($LineTeam['Average'],'.')));  //image creation
     138    }
     139    $System->Database->query('UPDATE `User` SET `NeedUpdate` = 0');
    128140  }
    129 
    130   // Main code for translation teams
    131   $DbResult = $System->Database->query('SELECT `ID`, `Name`, (SELECT AVG(`XP`) FROM `User` WHERE `Team` = `Team`.`Id`) AS `Average` '.
    132     'FROM `Team` WHERE `ID` IN (SELECT `Team` FROM `User` WHERE `NeedUpdate` = 1)');
    133   while($LineTeam = $DbResult->fetch_array())
    134   {
    135     CreateImg('team', $LineTeam['Name'], substr($LineTeam['Average'], 0, strpos($LineTeam['Average'],'.')));  //image creation
    136   }
    137   $System->Database->query('UPDATE `User` SET `NeedUpdate` = 0');
    138141}
    139142
Note: See TracChangeset for help on using the changeset viewer.