Changeset 455 for trunk/team.php
- Timestamp:
- Apr 13, 2010, 10:03:12 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/team.php
r411 r455 8 8 function ShowTeamList() 9 9 { 10 global $Config, $ Database, $User;10 global $Config, $System, $User; 11 11 12 12 echo('<h3>Seznam překladatelských týmů</h3>'); 13 13 echo('Týmy jsou seskupení překladatelů, kteří se hlásí k něčemu společnému jako např. WoW serveru, způsobu překladu, ke stejnému hernímu spolku, aj. Být členem týmu samo o sobě nemá žádný zásadní důsledek a spíše to může pomoci se lépe orientovat mezi překladateli někomu, kdo sestavuje export.<br/>'); 14 $DbResult = $ Database->SQLCommand('SELECT COUNT(*) FROM `Team`');15 $DbRow = mysql_fetch_row($DbResult);14 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Team`'); 15 $DbRow = $DbResult->fetch_row(); 16 16 $PageList = GetPageList($DbRow[0]); 17 17 … … 35 35 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 36 36 37 $ ID = $Database->SQLCommand('SELECT *, (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) AS `NumberUser`, (SELECT `Name` FROM `User` WHERE `User`.`ID`=`Team`.`Leader`) AS `LeaderName` FROM `Team` '.$_SESSION['search'].$Order['SQL'].$PageList['SQLLimit']);38 while($Team = mysql_fetch_assoc($ID))37 $DbResult = $System->Database->query('SELECT *, (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) AS `NumberUser`, (SELECT `Name` FROM `User` WHERE `User`.`ID`=`Team`.`Leader`) AS `LeaderName` FROM `Team` '.$_SESSION['search'].$Order['SQL'].$PageList['SQLLimit']); 38 while($Team = $DbResult->fetch_assoc()) 39 39 { 40 40 echo('<tr>'. … … 61 61 function TeamJoin() 62 62 { 63 global $ Database, $User;63 global $System, $User; 64 64 65 65 if($User->Licence(LICENCE_USER)) … … 67 67 if(array_key_exists('id', $_GET)) 68 68 { 69 $ Database->SQLCommand('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$User->Id);69 $System->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$User->Id); 70 70 echo('<strong>Vstoupil jsi do týmu</strong><br /><br />'); 71 71 WriteLog('Uživatel vstoupil do týmu '.$_GET['id'], LOG_TYPE_USER); 72 72 73 73 // Delete all teams without users 74 $ Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');74 $System->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 75 75 76 76 // Set new leader for teams where old leader went to other team 77 $ Database->SQLCommand('UPDATE `Team` SET `Leader`=(SELECT `Id` FROM `User` WHERE `User`.`Team`=`Team`.`Id` ORDER BY `User`.`RegistrationTime` LIMIT 1) WHERE `Leader` NOT IN (SELECT `ID` FROM `User` WHERE `User`.`Team`=`Team`.`Id`);');77 $System->Database->query('UPDATE `Team` SET `Leader`=(SELECT `Id` FROM `User` WHERE `User`.`Team`=`Team`.`Id` ORDER BY `User`.`RegistrationTime` LIMIT 1) WHERE `Leader` NOT IN (SELECT `ID` FROM `User` WHERE `User`.`Team`=`Team`.`Id`);'); 78 78 79 79 ShowTeamList(); … … 84 84 function TeamCreateFinish() 85 85 { 86 global $ Database, $User;86 global $System, $User; 87 87 88 88 if($User->Licence(LICENCE_USER)) … … 90 90 if(array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST)) 91 91 { 92 $DbResult = $ Database->SQLCommand('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"');93 $DbRow = mysql_fetch_row($DbResult);92 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"'); 93 $DbRow = $DbResult->fetch_row(); 94 94 $Count = $DbRow[0]; 95 95 if(($Count == 0) and ($_POST['Name'] != '')) 96 96 { 97 $ Database->SQLCommand('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`,`Leader`) VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'.$_POST['URL'].'", NOW(), '.$User->Id.')');98 $ Database->SQLCommand('UPDATE `User` SET `Team` = '.mysql_insert_id().' WHERE `ID` = '.$User->Id);97 $System->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`,`Leader`) VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'.$_POST['URL'].'", NOW(), '.$User->Id.')'); 98 $System->Database->query('UPDATE `User` SET `Team` = '.mysql_insert_id().' WHERE `ID` = '.$User->Id); 99 99 echo('<strong>Překladatelský tým vytvořen</strong><br /><br />'); 100 100 WriteLog('Překladatelský tým vytvořen '.$_POST['Name'], LOG_TYPE_USER); 101 101 102 102 // Delete all teams without users 103 $ Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');103 $System->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 104 104 } else echo('Již existuje tým se stejným jménem'); 105 105 } else echo('Chybí údaje formuláře'); … … 110 110 function TeamModify() 111 111 { 112 global $ Database, $User;112 global $System, $User; 113 113 114 114 if($User->Licence(LICENCE_USER)) … … 116 116 if(array_key_exists('id', $_GET)) 117 117 { 118 $DbResult = $ Database->SQLCommand('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);119 if( mysql_num_rows($DbResult)> 0)120 { 121 $Team = mysql_fetch_assoc($DbResult);118 $DbResult = $System->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id); 119 if($DbResult->num_rows > 0) 120 { 121 $Team = $DbResult->fetch_assoc(); 122 122 echo('<form action="?action=finish_modify&id='.$_GET['id'].'" method="post">'. 123 123 '<fieldset><legend>Nastavení týmu</legend>'. … … 134 134 function TeamModifyFinish() 135 135 { 136 global $ Database, $User;136 global $System, $User; 137 137 138 138 if($User->Licence(LICENCE_USER)) … … 140 140 if(array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST)) 141 141 { 142 $DbResult = $ Database->SQLCommand('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);143 if( mysql_num_rows($DbResult)> 0)144 { 145 $Team = mysql_fetch_assoc($DbResult);146 $DbResult = $ Database->SQLCommand('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"');147 $DbRow = mysql_fetch_row($DbResult);142 $DbResult = $System->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id); 143 if($DbResult->num_rows > 0) 144 { 145 $Team = $DbResult->fetch_assoc(); 146 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"'); 147 $DbRow = $DbResult->fetch_row(); 148 148 $Count = $DbRow[0]; 149 149 if(($Count == 0) and ($_POST['Name'] != '')) 150 150 { 151 $ Database->SQLCommand('UPDATE `Team` SET `Name`="'.$_POST['Name'].'", `Description`="'.$_POST['Description'].'", `URL`="'.$_POST['URL'].'" WHERE Id='.$Team['Id']);151 $System->Database->query('UPDATE `Team` SET `Name`="'.$_POST['Name'].'", `Description`="'.$_POST['Description'].'", `URL`="'.$_POST['URL'].'" WHERE Id='.$Team['Id']); 152 152 echo('Nastavení týmu uloženo.<br/>'); 153 153 WriteLog('Překladatelský tým upraven '.$_POST['Name'], LOG_TYPE_USER); … … 177 177 function TeamShow() 178 178 { 179 global $ Database, $TranslationTree, $User, $Config;179 global $System, $TranslationTree, $User, $Config; 180 180 181 181 if(array_key_exists('id', $_GET) and is_numeric($_GET['id'])) … … 183 183 ImgLevelUpdate(); 184 184 185 $DbResult = $ Database->SQLCommand('SELECT *, (SELECT COUNT(*) FROM `User` WHERE `Team` = `Team`.`Id`) AS `NumberUser`, (SELECT SUM(`TranslatedCount`) FROM `User` WHERE `team` = `Team`.`Id`) AS `NumberTranslate` FROM `Team` WHERE `Id`='.$_GET['id']);186 if( mysql_num_rows($DbResult)> 0)187 { 188 $Team = mysql_fetch_assoc($DbResult);189 $DbResult = $Database->SQLCommand('SELECT `Name` FROM `User` WHERE `ID`='.$Team['Leader']);190 if( mysql_num_rows($DbResult)> 0)191 { 192 $Leader = mysql_fetch_assoc($DbResult);185 $DbResult = $System->Database->query('SELECT *, (SELECT COUNT(*) FROM `User` WHERE `Team` = `Team`.`Id`) AS `NumberUser`, (SELECT SUM(`TranslatedCount`) FROM `User` WHERE `team` = `Team`.`Id`) AS `NumberTranslate` FROM `Team` WHERE `Id`='.$_GET['id']); 186 if($DbResult->num_rows > 0) 187 { 188 $Team = $DbResult->fetch_assoc(); 189 $DbResult2 = $System->Database->query('SELECT `Name` FROM `User` WHERE `ID`='.$Team['Leader']); 190 if($DbResult2->num_rows > 0) 191 { 192 $Leader = $DbResult2->fetch_assoc(); 193 193 $Leader = $Leader['Name']; 194 194 } else $Leader = ''; … … 210 210 $GroupListQuery = 'SELECT `Group`.* FROM `Group`'; 211 211 $Query = ''; 212 $DbResult = $ Database->SQLCommand($GroupListQuery);213 while($DbRow = mysql_fetch_assoc($DbResult))212 $DbResult = $System->Database->query($GroupListQuery); 213 while($DbRow = $DbResult->fetch_assoc()) 214 214 { 215 215 $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('. … … 224 224 $Query = substr($Query, 0, - 6); 225 225 226 $DbResult = $ Database->SQLCommand('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');227 $DbRow = mysql_fetch_row($DbResult);226 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`'); 227 $DbRow = $DbResult->fetch_row(); 228 228 $PageList = GetPageList($DbRow[0]); 229 229 echo($PageList['Output']); … … 242 242 $Translated = 0; 243 243 $Total = 0; 244 $ ID = $Database->SQLCommand('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.$Query.') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);245 while($Group = mysql_fetch_assoc($ID))244 $DbResult = $System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.$Query.') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']); 245 while($Group = $DbResult->fetch_assoc()) 246 246 { 247 247 echo('<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>'); … … 259 259 function TeamLeave() 260 260 { 261 global $ Database, $User;262 263 if($User->Licence(LICENCE_USER)) 264 { 265 $ Database->SQLCommand('UPDATE `User` SET `Team` = 0 WHERE `ID` = '.$User->Id);261 global $System, $User; 262 263 if($User->Licence(LICENCE_USER)) 264 { 265 $System->Database->query('UPDATE `User` SET `Team` = 0 WHERE `ID` = '.$User->Id); 266 266 echo('<strong>Nyní nejste členem žádného týmu</strong><br /><br />'); 267 267 WriteLog('Uživatel vystoupil z týmu', LOG_TYPE_USER); 268 268 269 269 // Delete all teams without users 270 $ Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');270 $System->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 271 271 272 272 // Set new leader for teams where old leader went to other team 273 $ Database->SQLCommand('UPDATE `Team` SET `Leader`=(SELECT `Id` FROM `User` WHERE `User`.`Team`=`Team`.`Id` ORDER BY `User`.`RegistrationTime` LIMIT 1) WHERE `Leader` NOT IN (SELECT `ID` FROM `User` WHERE `User`.`Team`=`Team`.`Id`);');273 $System->Database->query('UPDATE `Team` SET `Leader`=(SELECT `Id` FROM `User` WHERE `User`.`Team`=`Team`.`Id` ORDER BY `User`.`RegistrationTime` LIMIT 1) WHERE `Leader` NOT IN (SELECT `ID` FROM `User` WHERE `User`.`Team`=`Team`.`Id`);'); 274 274 275 275 ShowTeamList();
Note:
See TracChangeset
for help on using the changeset viewer.