- Timestamp:
- Jun 18, 2013, 6:21:04 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Team/Team.php
r544 r546 1 1 <?php 2 2 3 include('includes/global.php'); 3 class Team extends AppModule 4 { 5 function __construct($System) 6 { 7 parent::__construct($System); 8 $this->Name = 'Tean'; 9 $this->Version = '1.0'; 10 $this->Creator = 'Chronos'; 11 $this->License = 'GNU/GPL'; 12 $this->Description = 'Allow users to create teams similar to guilds in the game.'; 13 $this->Dependencies = array('User'); 14 } 15 16 function Start() 17 { 18 $this->System->RegisterPage('team.php', 'PageTeam'); 19 } 20 } 21 4 22 include_once('img_level.php'); 5 23 6 function ShowTeamList() 7 { 8 global $Config, $System, $User; 9 10 $Output = '<h3>Seznam překladatelských týmů</h3>'; 11 $Output .= '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/>'; 12 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Team`'); 13 $DbRow = $DbResult->fetch_row(); 14 $PageList = GetPageList($DbRow[0]); 15 16 $Output .= $PageList['Output']; 17 $Output .= '<table class="BaseTable">'; 18 19 $TableColumns = array( 20 array('Name' => 'Name', 'Title' => 'Jméno'), 21 array('Name' => 'URL', 'Title' => 'Webové stránky'), 22 array('Name' => 'LeaderName', 'Title' => 'Vedoucí'), 23 array('Name' => 'NumberUser', 'Title' => 'Počet členů'), 24 array('Name' => 'TimeCreate', 'Title' => 'Datum založení'), 25 ); 26 if($User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => 'Uživatelské akce'); 27 28 $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1); 29 $Output .= $Order['Output']; 30 31 if(array_key_exists('search', $_GET)) $_SESSION['search'] = ' WHERE `Name` LIKE "%'.$_GET['search'].'%" OR `Description` LIKE "%'.$_GET['search'].'%"'; 32 else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 33 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 34 35 $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']); 36 while($Team = $DbResult->fetch_assoc()) 37 { 38 $Output .= '<tr>'. 39 '<td><a href="?action=team&id='.$Team['Id'].'">'.$Team['Name'].'</a></td>'. 40 '<td><a href="http://'.$Team['URL'].'">'.$Team['URL'].'</a></td>'. 41 '<td><a href="'.$System->Link('/user.php?user='.$Team['Leader']).'">'.$Team['LeaderName'].'</a></td>'. 42 '<td><a href="userlist.php?team='.$Team['Id'].'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a></td>'. 43 '<td>'.HumanDate($Team['TimeCreate']).'</td>'; 44 if($User->Licence(LICENCE_USER)) 45 { 46 if($Team['Leader'] == $User->Id) $Action = ' <a href="?action=modify&id='.$Team['Id'].'">Upravit</a>'; 47 else $Action = ''; 48 if($Team['Id'] == $User->Team) $Action = ' <a href="?action=leave">Opustit</a>'; 49 $Output .= '<td><a href="?action=gointeam&id='.$Team['Id'].'">Vstoupit</a>'.$Action.'</td>'; 50 } 51 $Output .= '</tr>'; 52 } 53 $Output .= '</table>'. 54 $PageList['Output']; 55 56 if($User->Licence(LICENCE_USER)) 57 $Output .= '<br /><div style="text-align: center;"><a href="?action=create">Vytvořit překladatelský tým</a></div>'; 58 return($Output); 59 } 60 61 function TeamJoin() 24 class PageTeam extends Page 62 25 { 63 global $System, $User; 64 65 if($User->Licence(LICENCE_USER)) 66 { 67 if(array_key_exists('id', $_GET)) 68 { 69 $System->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$User->Id); 70 $Output = ShowMessage('Vstoupil jsi do týmu.'); 71 WriteLog('Uživatel vstoupil do týmu '.$_GET['id'], LOG_TYPE_USER); 72 73 // Delete all teams without users 74 $System->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 75 76 // Set new leader for teams where old leader went to other team 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 79 $Output .= ShowTeamList(); 80 } else $Output = ShowMessage('Nutno zadat id týmu.', MESSAGE_CRITICAL); 81 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 82 return($Output); 26 function ShowTeamList() 27 { 28 global $Config, $User; 29 30 $Output = '<h3>Seznam překladatelských týmů</h3>'; 31 $Output .= '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/>'; 32 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team`'); 33 $DbRow = $DbResult->fetch_row(); 34 $PageList = GetPageList($DbRow[0]); 35 36 $Output .= $PageList['Output']; 37 $Output .= '<table class="BaseTable">'; 38 39 $TableColumns = array( 40 array('Name' => 'Name', 'Title' => 'Jméno'), 41 array('Name' => 'URL', 'Title' => 'Webové stránky'), 42 array('Name' => 'LeaderName', 'Title' => 'Vedoucí'), 43 array('Name' => 'NumberUser', 'Title' => 'Počet členů'), 44 array('Name' => 'TimeCreate', 'Title' => 'Datum založení'), 45 ); 46 if($User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => 'Uživatelské akce'); 47 48 $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1); 49 $Output .= $Order['Output']; 50 51 if(array_key_exists('search', $_GET)) $_SESSION['search'] = ' WHERE `Name` LIKE "%'.$_GET['search'].'%" OR `Description` LIKE "%'.$_GET['search'].'%"'; 52 else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 53 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 54 55 $DbResult = $this->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']); 56 while($Team = $DbResult->fetch_assoc()) 57 { 58 $Output .= '<tr>'. 59 '<td><a href="?action=team&id='.$Team['Id'].'">'.$Team['Name'].'</a></td>'. 60 '<td><a href="http://'.$Team['URL'].'">'.$Team['URL'].'</a></td>'. 61 '<td><a href="'.$this->System->Link('/user.php?user='.$Team['Leader']).'">'.$Team['LeaderName'].'</a></td>'. 62 '<td><a href="userlist.php?team='.$Team['Id'].'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a></td>'. 63 '<td>'.HumanDate($Team['TimeCreate']).'</td>'; 64 if($User->Licence(LICENCE_USER)) 65 { 66 if($Team['Leader'] == $User->Id) $Action = ' <a href="?action=modify&id='.$Team['Id'].'">Upravit</a>'; 67 else $Action = ''; 68 if($Team['Id'] == $User->Team) $Action = ' <a href="?action=leave">Opustit</a>'; 69 $Output .= '<td><a href="?action=gointeam&id='.$Team['Id'].'">Vstoupit</a>'.$Action.'</td>'; 70 } 71 $Output .= '</tr>'; 72 } 73 $Output .= '</table>'. 74 $PageList['Output']; 75 76 if($User->Licence(LICENCE_USER)) 77 $Output .= '<br /><div style="text-align: center;"><a href="?action=create">Vytvořit překladatelský tým</a></div>'; 78 return($Output); 79 } 80 81 function TeamJoin() 82 { 83 global $User; 84 85 if($User->Licence(LICENCE_USER)) 86 { 87 if(array_key_exists('id', $_GET)) 88 { 89 $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$User->Id); 90 $Output = ShowMessage('Vstoupil jsi do týmu.'); 91 WriteLog('Uživatel vstoupil do týmu '.$_GET['id'], LOG_TYPE_USER); 92 93 // Delete all teams without users 94 $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 95 96 // Set new leader for teams where old leader went to other team 97 $this->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`);'); 98 99 $Output .= $this->ShowTeamList(); 100 } else $Output = ShowMessage('Nutno zadat id týmu.', MESSAGE_CRITICAL); 101 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 102 return($Output); 103 } 104 105 function TeamCreateFinish() 106 { 107 global $User; 108 109 $Output = ''; 110 if($User->Licence(LICENCE_USER)) 111 { 112 if(array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST)) 113 { 114 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"'); 115 $DbRow = $DbResult->fetch_row(); 116 $Count = $DbRow[0]; 117 if(($Count == 0) and ($_POST['Name'] != '')) 118 { 119 $this->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'. 120 ' VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'. 121 $_POST['URL'].'", NOW(), '.$User->Id.')'); 122 $this->Database->query('UPDATE `User` SET `Team` = '.$this->Database->insert_id.' WHERE `ID` = '.$User->Id); 123 $Output .= ShowMessage('Překladatelský tým vytvořen.'); 124 WriteLog('Překladatelský tým vytvořen '.$_POST['Name'], LOG_TYPE_USER); 125 126 // Delete all teams without users 127 $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 128 } else $Output .= ShowMessage('Již existuje tým se stejným jménem', MESSAGE_CRITICAL); 129 } else $Output .= ShowMessage('Chybí údaje formuláře', MESSAGE_CRITICAL); 130 } else $Output .= ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 131 $Output .= $this->ShowTeamList(); 132 return($Output); 133 } 134 135 function TeamModify() 136 { 137 global $User; 138 139 if($User->Licence(LICENCE_USER)) 140 { 141 if(array_key_exists('id', $_GET)) 142 { 143 $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id); 144 if($DbResult->num_rows > 0) 145 { 146 $Team = $DbResult->fetch_assoc(); 147 $Output = '<form action="?action=finish_modify&id='.$_GET['id'].'" method="post">'. 148 '<fieldset><legend>Nastavení týmu</legend>'. 149 '<table><tr><td>Jméno:</td><td><input type="text" name="Name" value="'.$Team['Name'].'"/></td></tr>'. 150 '<tr><td>Webové stránky:</td><td>http://<input type="text" name="URL" value="'.$Team['URL'].'"/></td></tr>'. 151 '<tr><td>Popis:</td><td><input type="text" name="Description" value="'.$Team['Description'].'"/></td></tr>'. 152 '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'. 153 '</table></fieldset></form>'; 154 } else $Output = ShowMesage('Tým nenalezen.', MESSAGE_CRITICAL); 155 } else $Output = ShowMessage('Nezadáno id týmu', MESSAGE_CRITICAL); 156 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 157 return($Output); 158 } 159 160 function TeamModifyFinish() 161 { 162 global $User; 163 164 $Output = ''; 165 if($User->Licence(LICENCE_USER)) 166 { 167 if(array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST)) 168 { 169 $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id); 170 if($DbResult->num_rows > 0) 171 { 172 $Team = $DbResult->fetch_assoc(); 173 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"'); 174 $DbRow = $DbResult->fetch_row(); 175 $Count = $DbRow[0]; 176 if(($Count == 0) and ($_POST['Name'] != '')) 177 { 178 $this->Database->query('UPDATE `Team` SET `Name`="'.$_POST['Name'].'", `Description`="'.$_POST['Description'].'", `URL`="'.$_POST['URL'].'" WHERE Id='.$Team['Id']); 179 $Output .= ShowMessage('Nastavení týmu uloženo.'); 180 WriteLog('Překladatelský tým upraven '.$_POST['Name'], LOG_TYPE_USER); 181 } else $Output .= ShowMessage('Již existuje tým se stejným jménem.', MESSAGE_CRITICAL); 182 } else $Output .= ShowMessage('Tým nenalezen nebo nemáte oprávnění.', MESSAGE_CRITICAL); 183 } else $Output .= ShowMessage('Nezadáno id týmu nebo některé položky formuláře.', MESSAGE_CRITICAL); 184 } else $Output .= ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 185 $Output .= $this->ShowTeamList(); 186 return($Output); 187 } 188 189 function TeamCreate() 190 { 191 global $User; 192 193 if($User->Licence(LICENCE_USER)) 194 { 195 $Output ='<form action="?action=finish_create" method="post">'. 196 '<fieldset><legend>Vytvoření nového týmu</legend>'. 197 '<table><tr><td>Jméno:</td><td><input type="text" name="Name" /></td></tr>'. 198 '<tr><td>Webové stránky:</td><td>http://<input type="text" name="URL" value=""/></td></tr>'. 199 '<tr><td>Popis:</td><td><input type="text" name="Description" /></td></tr>'. 200 '<tr><td colspan="2"><input type="submit" value="Vytvořit a vstoupit" /></td></tr>'. 201 '</table></fieldset></form>'; 202 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 203 return($Output); 204 } 205 206 function TeamShow() 207 { 208 global $User, $Config; 209 210 $Output = ''; 211 if(array_key_exists('id', $_GET) and is_numeric($_GET['id'])) 212 { 213 ImgLevelUpdate(); 214 215 $DbResult = $this->Database->query('SELECT `Id`, `Name`, `Description`, `URL`, `Leader`, '. 216 '(SELECT COUNT(*) FROM `User` WHERE '. 217 '`Team` = `Team`.`Id`) AS `NumberUser`, (SELECT SUM(`TranslatedCount`) FROM `User` WHERE '. 218 '`Team` = `Team`.`Id`) AS `NumberTranslate` FROM '. 219 '`Team` WHERE `Id`='.($_GET['id'] * 1)); 220 if($DbResult->num_rows > 0) 221 { 222 $Team = $DbResult->fetch_assoc(); 223 $DbResult2 = $this->Database->query('SELECT `Name`, `Id` FROM `User` WHERE `ID`='.$Team['Leader']); 224 if($DbResult2->num_rows > 0) 225 { 226 $Leader = $DbResult2->fetch_assoc(); 227 } else $Leader = array('Name' => '', 'Id' => 0); 228 229 $Output .='<strong>Překladatelský tým '.$Team['Name'].'</strong><br />'. 230 'Webové stránky: <a href="http://'.$Team['URL'].'">'.$Team['URL'].'</a><br/>'. 231 'Vedoucí: <a href="'.$this->System->Link('/user.php?user='.$Leader['Id']).'">'.$Leader['Name'].'</a><br/>'. 232 'Popis: '.$Team['Description'].'<br /><br />'; 233 //$Output .= '<a href="export/?team='.$Team['Id'].'">Exportovat překlad týmu</a> '; 234 if($User->Licence(LICENCE_USER)) 235 $Output .='<a href="?action=gointeam&id='.$Team['Id'].'">Vstoupit do týmu</a><br /><br />'; 236 $Output .='<fieldset><legend>Statistika</legend>'. 237 'Počet členů týmu: <a href="userlist.php?team='.$Team['Id'].'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a><br />'. 238 'Počet přeložených textů týmu: <strong>'.$Team['NumberTranslate'].'</strong><br />'. 239 'Průměrná úroveň překladatelů v týmu: <img src="tmp/team/'.$Team['Name'].'/level.png" /><br /><br />'. 240 '<strong>Stav dokončení týmu pro verzi '.$Config['Web']['GameVersion'].'</strong><br />'; 241 242 $BuildNumber = GetBuildNumber($Config['Web']['GameVersion']); 243 244 $GroupListQuery = 'SELECT `Group`.* FROM `Group`'; 245 $Query = ''; 246 $DbResult = $this->Database->query($GroupListQuery); 247 if($DbResult->num_rows > 0) 248 { 249 while($DbRow = $DbResult->fetch_assoc()) 250 { 251 $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 252 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '. 253 'WHERE (`User` IN (SELECT `ID` FROM `User` WHERE `Team` = '.$Team['Id'].')) '. 254 'AND (`Complete` = 1) AND (`T`.`Language`!='.$Config['OriginalLanguage'].') '. 255 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'. 256 ') AS `C1`) AS `Translated`, '. 257 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 258 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '. 259 'WHERE (`Language` = '.$Config['OriginalLanguage'].') '. 260 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'. 261 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION '; 262 } 263 $Query = substr($Query, 0, - 6); 264 265 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`'); 266 $DbRow = $DbResult->fetch_row(); 267 $PageList = GetPageList($DbRow[0]); 268 $Output .= $PageList['Output']; 269 270 $Output .='<table class="BaseTable">'; 271 $TableColumns = array( 272 array('Name' => 'Name', 'Title' => 'Jméno'), 273 array('Name' => 'Translated', 'Title' => 'Přeložených'), 274 array('Name' => 'Total', 'Title' => 'Anglických'), 275 array('Name' => 'Percent', 'Title' => 'Procenta'), 276 ); 277 278 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 279 $Output .= $Order['Output']; 280 281 $Translated = 0; 282 $Total = 0; 283 $DbResult = $this->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.$Query.') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']); 284 while($Group = $DbResult->fetch_assoc()) 285 { 286 $Output .='<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>'; 287 $Translated += $Group['Translated']; 288 $Total += $Group['Total']; 289 } 290 if($Total > 0) $Progress = round($Translated / $Total * 100, 2); 291 else $Progress = 0; 292 $Output .='<tr><td><strong>Celkem</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, $Progress).'</strong></td></tr>'; 293 $Output .='</table>'; 294 } 295 $Output .='</fieldset>'; 296 } else $Output .= ShowMessage('Tým nenalezen', MESSAGE_CRITICAL); 297 } else $Output .= ShowMessage('Musíte zadat id týmu', MESSAGE_CRITICAL); 298 return($Output); 299 } 300 301 function TeamLeave() 302 { 303 global $User; 304 305 if($User->Licence(LICENCE_USER)) 306 { 307 $this->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$User->Id); 308 $Output = ShowMessage('Nyní nejste členem žádného týmu.'); 309 WriteLog('Uživatel vystoupil z týmu', LOG_TYPE_USER); 310 311 // Delete all teams without users 312 $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0'); 313 314 // Set new leader for teams where old leader went to other team 315 $this->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`);'); 316 317 $Output .= $this->ShowTeamList(); 318 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL); 319 return($Output); 320 } 321 322 function Show() 323 { 324 if(array_key_exists('action', $_GET)) 325 { 326 if($_GET['action'] == 'gointeam') $Output = $this->TeamJoin(); 327 else if($_GET['action'] == 'finish_create') $Output = $this->TeamCreateFinish(); 328 else if($_GET['action'] == 'modify') $Output = $this->TeamModify(); 329 else if($_GET['action'] == 'finish_modify') $Output = $this->TeamModifyFinish(); 330 else if($_GET['action'] == 'create') $Output = $this->TeamCreate(); 331 else if($_GET['action'] == 'team') $Output = $this->TeamShow(); 332 else if($_GET['action'] == 'leave') $Output = $this->TeamLeave(); 333 else $Output = $this->ShowTeamList(); 334 } else $Output = $this->ShowTeamList(); 335 return($Output); 336 } 83 337 } 84 85 function TeamCreateFinish()86 {87 global $System, $User;88 89 $Output = '';90 if($User->Licence(LICENCE_USER))91 {92 if(array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST))93 {94 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"');95 $DbRow = $DbResult->fetch_row();96 $Count = $DbRow[0];97 if(($Count == 0) and ($_POST['Name'] != ''))98 {99 $System->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'.100 ' VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'.101 $_POST['URL'].'", NOW(), '.$User->Id.')');102 $System->Database->query('UPDATE `User` SET `Team` = '.$System->Database->insert_id.' WHERE `ID` = '.$User->Id);103 $Output .= ShowMessage('Překladatelský tým vytvořen.');104 WriteLog('Překladatelský tým vytvořen '.$_POST['Name'], LOG_TYPE_USER);105 106 // Delete all teams without users107 $System->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');108 } else $Output .= ShowMessage('Již existuje tým se stejným jménem', MESSAGE_CRITICAL);109 } else $Output .= ShowMessage('Chybí údaje formuláře', MESSAGE_CRITICAL);110 } else $Output .= ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL);111 $Output .= ShowTeamList();112 return($Output);113 }114 115 function TeamModify()116 {117 global $System, $User;118 119 if($User->Licence(LICENCE_USER))120 {121 if(array_key_exists('id', $_GET))122 {123 $DbResult = $System->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);124 if($DbResult->num_rows > 0)125 {126 $Team = $DbResult->fetch_assoc();127 $Output = '<form action="?action=finish_modify&id='.$_GET['id'].'" method="post">'.128 '<fieldset><legend>Nastavení týmu</legend>'.129 '<table><tr><td>Jméno:</td><td><input type="text" name="Name" value="'.$Team['Name'].'"/></td></tr>'.130 '<tr><td>Webové stránky:</td><td>http://<input type="text" name="URL" value="'.$Team['URL'].'"/></td></tr>'.131 '<tr><td>Popis:</td><td><input type="text" name="Description" value="'.$Team['Description'].'"/></td></tr>'.132 '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'.133 '</table></fieldset></form>';134 } else $Output = ShowMesage('Tým nenalezen.', MESSAGE_CRITICAL);135 } else $Output = ShowMessage('Nezadáno id týmu', MESSAGE_CRITICAL);136 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL);137 return($Output);138 }139 140 function TeamModifyFinish()141 {142 global $System, $User;143 144 $Output = '';145 if($User->Licence(LICENCE_USER))146 {147 if(array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST))148 {149 $DbResult = $System->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);150 if($DbResult->num_rows > 0)151 {152 $Team = $DbResult->fetch_assoc();153 $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"');154 $DbRow = $DbResult->fetch_row();155 $Count = $DbRow[0];156 if(($Count == 0) and ($_POST['Name'] != ''))157 {158 $System->Database->query('UPDATE `Team` SET `Name`="'.$_POST['Name'].'", `Description`="'.$_POST['Description'].'", `URL`="'.$_POST['URL'].'" WHERE Id='.$Team['Id']);159 $Output .= ShowMessage('Nastavení týmu uloženo.');160 WriteLog('Překladatelský tým upraven '.$_POST['Name'], LOG_TYPE_USER);161 } else $Output .= ShowMessage('Již existuje tým se stejným jménem.', MESSAGE_CRITICAL);162 } else $Output .= ShowMessage('Tým nenalezen nebo nemáte oprávnění.', MESSAGE_CRITICAL);163 } else $Output .= ShowMessage('Nezadáno id týmu nebo některé položky formuláře.', MESSAGE_CRITICAL);164 } else $Output .= ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL);165 $Output .= ShowTeamList();166 return($Output);167 }168 169 function TeamCreate()170 {171 global $User;172 173 if($User->Licence(LICENCE_USER))174 {175 $Output ='<form action="?action=finish_create" method="post">'.176 '<fieldset><legend>Vytvoření nového týmu</legend>'.177 '<table><tr><td>Jméno:</td><td><input type="text" name="Name" /></td></tr>'.178 '<tr><td>Webové stránky:</td><td>http://<input type="text" name="URL" value=""/></td></tr>'.179 '<tr><td>Popis:</td><td><input type="text" name="Description" /></td></tr>'.180 '<tr><td colspan="2"><input type="submit" value="Vytvořit a vstoupit" /></td></tr>'.181 '</table></fieldset></form>';182 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL);183 return($Output);184 }185 186 function TeamShow()187 {188 global $System, $User, $Config;189 190 $Output = '';191 if(array_key_exists('id', $_GET) and is_numeric($_GET['id']))192 {193 ImgLevelUpdate();194 195 $DbResult = $System->Database->query('SELECT `Id`, `Name`, `Description`, `URL`, `Leader`, '.196 '(SELECT COUNT(*) FROM `User` WHERE '.197 '`Team` = `Team`.`Id`) AS `NumberUser`, (SELECT SUM(`TranslatedCount`) FROM `User` WHERE '.198 '`Team` = `Team`.`Id`) AS `NumberTranslate` FROM '.199 '`Team` WHERE `Id`='.($_GET['id'] * 1));200 if($DbResult->num_rows > 0)201 {202 $Team = $DbResult->fetch_assoc();203 $DbResult2 = $System->Database->query('SELECT `Name`, `Id` FROM `User` WHERE `ID`='.$Team['Leader']);204 if($DbResult2->num_rows > 0)205 {206 $Leader = $DbResult2->fetch_assoc();207 } else $Leader = array('Name' => '', 'Id' => 0);208 209 $Output .='<strong>Překladatelský tým '.$Team['Name'].'</strong><br />'.210 'Webové stránky: <a href="http://'.$Team['URL'].'">'.$Team['URL'].'</a><br/>'.211 'Vedoucí: <a href="'.$System->Link('/user.php?user='.$Leader['Id']).'">'.$Leader['Name'].'</a><br/>'.212 'Popis: '.$Team['Description'].'<br /><br />';213 //$Output .= '<a href="export/?team='.$Team['Id'].'">Exportovat překlad týmu</a> ';214 if($User->Licence(LICENCE_USER))215 $Output .='<a href="?action=gointeam&id='.$Team['Id'].'">Vstoupit do týmu</a><br /><br />';216 $Output .='<fieldset><legend>Statistika</legend>'.217 'Počet členů týmu: <a href="userlist.php?team='.$Team['Id'].'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a><br />'.218 'Počet přeložených textů týmu: <strong>'.$Team['NumberTranslate'].'</strong><br />'.219 'Průměrná úroveň překladatelů v týmu: <img src="tmp/team/'.$Team['Name'].'/level.png" /><br /><br />'.220 '<strong>Stav dokončení týmu pro verzi '.$Config['Web']['GameVersion'].'</strong><br />';221 222 $BuildNumber = GetBuildNumber($Config['Web']['GameVersion']);223 224 $GroupListQuery = 'SELECT `Group`.* FROM `Group`';225 $Query = '';226 $DbResult = $System->Database->query($GroupListQuery);227 if($DbResult->num_rows > 0)228 {229 while($DbRow = $DbResult->fetch_assoc())230 {231 $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.232 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.233 'WHERE (`User` IN (SELECT `ID` FROM `User` WHERE `Team` = '.$Team['Id'].')) '.234 'AND (`Complete` = 1) AND (`T`.`Language`!='.$Config['OriginalLanguage'].') '.235 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.236 ') AS `C1`) AS `Translated`, '.237 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.238 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.239 'WHERE (`Language` = '.$Config['OriginalLanguage'].') '.240 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.241 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION ';242 }243 $Query = substr($Query, 0, - 6);244 245 $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');246 $DbRow = $DbResult->fetch_row();247 $PageList = GetPageList($DbRow[0]);248 $Output .= $PageList['Output'];249 250 $Output .='<table class="BaseTable">';251 $TableColumns = array(252 array('Name' => 'Name', 'Title' => 'Jméno'),253 array('Name' => 'Translated', 'Title' => 'Přeložených'),254 array('Name' => 'Total', 'Title' => 'Anglických'),255 array('Name' => 'Percent', 'Title' => 'Procenta'),256 );257 258 $Order = GetOrderTableHeader($TableColumns, 'Name', 0);259 $Output .= $Order['Output'];260 261 $Translated = 0;262 $Total = 0;263 $DbResult = $System->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.$Query.') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);264 while($Group = $DbResult->fetch_assoc())265 {266 $Output .='<tr><td>'.$Group['Name'].'</td><td>'.$Group['Translated'].'</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>';267 $Translated += $Group['Translated'];268 $Total += $Group['Total'];269 }270 if($Total > 0) $Progress = round($Translated / $Total * 100, 2);271 else $Progress = 0;272 $Output .='<tr><td><strong>Celkem</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, $Progress).'</strong></td></tr>';273 $Output .='</table>';274 }275 $Output .='</fieldset>';276 } else $Output .=ShowMessage('Tým nenalezen', MESSAGE_CRITICAL);277 } else $Output .=ShowMessage('Musíte zadat id týmu', MESSAGE_CRITICAL);278 return($Output);279 }280 281 function TeamLeave()282 {283 global $System, $User;284 285 if($User->Licence(LICENCE_USER))286 {287 $System->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$User->Id);288 $Output = ShowMessage('Nyní nejste členem žádného týmu.');289 WriteLog('Uživatel vystoupil z týmu', LOG_TYPE_USER);290 291 // Delete all teams without users292 $System->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');293 294 // Set new leader for teams where old leader went to other team295 $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`);');296 297 $Output .=ShowTeamList();298 } else $Output = ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL);299 return($Output);300 }301 302 if(array_key_exists('action', $_GET))303 {304 if($_GET['action'] == 'gointeam') $Output = TeamJoin();305 else if($_GET['action'] == 'finish_create') $Output = TeamCreateFinish();306 else if($_GET['action'] == 'modify') $Output = TeamModify();307 else if($_GET['action'] == 'finish_modify') $Output = TeamModifyFinish();308 else if($_GET['action'] == 'create') $Output =TeamCreate();309 else if($_GET['action'] == 'team') $Output = TeamShow();310 else if($_GET['action'] == 'leave') $Output = TeamLeave();311 else $Output = ShowTeamList();312 } else $Output = ShowTeamList();313 314 ShowPage($Output);315 316 ?> -
trunk/includes/Version.php
r545 r546 1 1 <?php 2 2 3 $Revision = 54 5; // Subversion revision3 $Revision = 546; // Subversion revision 4 4 $DatabaseRevision = 543; // Database structure revision 5 5 $ReleaseTime = '2013-06-18'; -
trunk/includes/global.php
r545 r546 18 18 include_once(dirname(__FILE__).'/../Modules/Referrer/Referrer.php'); 19 19 include_once(dirname(__FILE__).'/../Modules/FrontPage/FrontPage.php'); 20 include_once(dirname(__FILE__).'/../Modules/Team/Team.php'); 20 21 21 22 GlobalInit(); … … 65 66 $System->ModuleManager->Modules['Referrer']->Excluded[] = $System->Config['Web']['Host']; 66 67 $System->ModuleManager->RegisterModule(new FrontPage($System)); 68 $System->ModuleManager->RegisterModule(new Team($System)); 67 69 $System->ModuleManager->StartAll(); 68 70 }
Note:
See TracChangeset
for help on using the changeset viewer.