| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | class ModuleTeam extends Module
|
|---|
| 4 | {
|
|---|
| 5 | function __construct(System $System)
|
|---|
| 6 | {
|
|---|
| 7 | parent::__construct($System);
|
|---|
| 8 | $this->Name = 'Team';
|
|---|
| 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 DoStart(): void
|
|---|
| 17 | {
|
|---|
| 18 | $this->System->RegisterPage(['team'], 'PageTeam');
|
|---|
| 19 | Core::Cast($this->System)->RegisterMenuItem(array(
|
|---|
| 20 | 'Title' => T('Teams'),
|
|---|
| 21 | 'Hint' => T('List of translating teams'),
|
|---|
| 22 | 'Link' => $this->System->Link('/team/'),
|
|---|
| 23 | 'Permission' => LICENCE_ANONYMOUS,
|
|---|
| 24 | 'Icon' => '',
|
|---|
| 25 | ), 1);
|
|---|
| 26 | if (array_key_exists('Search', $this->System->ModuleManager->Modules))
|
|---|
| 27 | $this->System->ModuleManager->Modules['Search']->RegisterSearch('team',
|
|---|
| 28 | T('Teams'), array('Name'), '`Team`', $this->System->Link('/team/?search='));
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | class PageTeam extends Page
|
|---|
| 33 | {
|
|---|
| 34 | function ShowTeamList()
|
|---|
| 35 | {
|
|---|
| 36 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 37 | $this->Title = T('Teams');
|
|---|
| 38 | $Output = '<h3>'.T('List of translating teams').'</h3>';
|
|---|
| 39 | $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/>';
|
|---|
| 40 |
|
|---|
| 41 | if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
|
|---|
| 42 | else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
|
|---|
| 43 | if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
|
|---|
| 44 |
|
|---|
| 45 | if ($User->Licence(LICENCE_USER))
|
|---|
| 46 | $Output .= '<br /><div style="text-align: center;"><a href="?action=create">'.T('Create translating team').'</a></div><br/>';
|
|---|
| 47 | if ($_SESSION['search'] != '')
|
|---|
| 48 | {
|
|---|
| 49 | $SearchQuery = ' AND ((`Name` LIKE "%'.$_SESSION['search'].'%") OR (`Description` LIKE "%'.$_SESSION['search'].'%"))';
|
|---|
| 50 | $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), htmlspecialchars($_SESSION['search'])).'</a></div>';
|
|---|
| 51 | } else $SearchQuery = '';
|
|---|
| 52 |
|
|---|
| 53 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE 1'.$SearchQuery);
|
|---|
| 54 | $DbRow = $DbResult->fetch_row();
|
|---|
| 55 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 56 |
|
|---|
| 57 | $Output .= $PageList['Output'];
|
|---|
| 58 | $Output .= '<table class="BaseTable">';
|
|---|
| 59 |
|
|---|
| 60 | $TableColumns = array(
|
|---|
| 61 | array('Name' => 'Name', 'Title' => T('Name')),
|
|---|
| 62 | array('Name' => 'URL', 'Title' => T('Web pages')),
|
|---|
| 63 | array('Name' => 'LeaderName', 'Title' => T('Leader')),
|
|---|
| 64 | array('Name' => 'NumberUser', 'Title' => T('Member count')),
|
|---|
| 65 | array('Name' => 'TimeCreate', 'Title' => T('Founding date')),
|
|---|
| 66 | );
|
|---|
| 67 | if ($User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('User actions'));
|
|---|
| 68 |
|
|---|
| 69 | $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1);
|
|---|
| 70 | $Output .= $Order['Output'];
|
|---|
| 71 |
|
|---|
| 72 | $DbResult = $this->Database->query('SELECT *, (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) AS `NumberUser`, '.
|
|---|
| 73 | '(SELECT `Name` FROM `User` WHERE `User`.`ID`=`Team`.`Leader`) AS `LeaderName` '.
|
|---|
| 74 | 'FROM `Team` WHERE 1'.$SearchQuery.$Order['SQL'].$PageList['SQLLimit']);
|
|---|
| 75 | while ($Team = $DbResult->fetch_assoc())
|
|---|
| 76 | {
|
|---|
| 77 | $Output .= '<tr>'.
|
|---|
| 78 | '<td><a href="?action=team&id='.$Team['Id'].'">'.htmlspecialchars($Team['Name']).'</a></td>'.
|
|---|
| 79 | '<td><a href="http://'.$Team['URL'].'">'.htmlspecialchars($Team['URL']).'</a></td>'.
|
|---|
| 80 | '<td><a href="'.$this->System->Link('/user/?user='.$Team['Leader']).'">'.$Team['LeaderName'].'</a></td>'.
|
|---|
| 81 | '<td><a href="'.$this->System->Link('/users/?team='.$Team['Id']).'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a></td>'.
|
|---|
| 82 | '<td>'.HumanDate($Team['TimeCreate']).'</td>';
|
|---|
| 83 | if ($User->Licence(LICENCE_USER))
|
|---|
| 84 | {
|
|---|
| 85 | if ($Team['Leader'] == $User->Id) $Action = ' <a href="?action=modify&id='.$Team['Id'].'">'.T('Edit').'</a>';
|
|---|
| 86 | else $Action = '';
|
|---|
| 87 | if ($Team['Id'] == $User->Team) $Action = ' <a href="?action=leave">'.T('Leave').'</a>';
|
|---|
| 88 | $Output .= '<td><a href="?action=gointeam&id='.$Team['Id'].'">'.T('Enter').'</a>'.$Action.'</td>';
|
|---|
| 89 | }
|
|---|
| 90 | $Output .= '</tr>';
|
|---|
| 91 | }
|
|---|
| 92 | $Output .= '</table>'.
|
|---|
| 93 | $PageList['Output'];
|
|---|
| 94 |
|
|---|
| 95 | return $Output;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | function TeamJoin()
|
|---|
| 99 | {
|
|---|
| 100 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 101 | if ($User->Licence(LICENCE_USER))
|
|---|
| 102 | {
|
|---|
| 103 | if (array_key_exists('id', $_GET))
|
|---|
| 104 | {
|
|---|
| 105 | $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$User->Id);
|
|---|
| 106 | $Output = ShowMessage(T('You joined new team'));
|
|---|
| 107 | $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel vstoupil do týmu '.$_GET['id'], LOG_TYPE_USER);
|
|---|
| 108 |
|
|---|
| 109 | // Delete all teams without users
|
|---|
| 110 | $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');
|
|---|
| 111 |
|
|---|
| 112 | // Set new leader for teams where old leader went to other team
|
|---|
| 113 | $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`);');
|
|---|
| 114 |
|
|---|
| 115 | $Output .= $this->ShowTeamList();
|
|---|
| 116 | } else $Output = ShowMessage('Nutno zadat id týmu.', MESSAGE_CRITICAL);
|
|---|
| 117 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 118 | return $Output;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | function TeamCreateFinish()
|
|---|
| 122 | {
|
|---|
| 123 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 124 | $Output = '';
|
|---|
| 125 | if ($User->Licence(LICENCE_USER))
|
|---|
| 126 | {
|
|---|
| 127 | if (array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST))
|
|---|
| 128 | {
|
|---|
| 129 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"');
|
|---|
| 130 | $DbRow = $DbResult->fetch_row();
|
|---|
| 131 | $Count = $DbRow[0];
|
|---|
| 132 | if (($Count == 0) and ($_POST['Name'] != ''))
|
|---|
| 133 | {
|
|---|
| 134 | $this->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'.
|
|---|
| 135 | ' VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'.
|
|---|
| 136 | $_POST['URL'].'", NOW(), '.$User->Id.')');
|
|---|
| 137 | $this->Database->query('UPDATE `User` SET `Team` = '.$this->Database->insert_id.' WHERE `ID` = '.$User->Id);
|
|---|
| 138 | $Output .= ShowMessage('Překladatelský tým vytvořen.');
|
|---|
| 139 | $this->System->ModuleManager->Modules['Log']->WriteLog('Překladatelský tým vytvořen '.$_POST['Name'], LOG_TYPE_USER);
|
|---|
| 140 |
|
|---|
| 141 | // Delete all teams without users
|
|---|
| 142 | $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');
|
|---|
| 143 | } else $Output .= ShowMessage('Již existuje tým se stejným jménem', MESSAGE_CRITICAL);
|
|---|
| 144 | } else $Output .= ShowMessage('Chybí údaje formuláře', MESSAGE_CRITICAL);
|
|---|
| 145 | } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 146 | $Output .= $this->ShowTeamList();
|
|---|
| 147 | return $Output;
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | function TeamModify()
|
|---|
| 151 | {
|
|---|
| 152 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 153 | if ($User->Licence(LICENCE_USER))
|
|---|
| 154 | {
|
|---|
| 155 | if (array_key_exists('id', $_GET))
|
|---|
| 156 | {
|
|---|
| 157 | $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);
|
|---|
| 158 | if ($DbResult->num_rows > 0)
|
|---|
| 159 | {
|
|---|
| 160 | $Team = $DbResult->fetch_assoc();
|
|---|
| 161 | $Output = '<form action="?action=finish_modify&id='.$_GET['id'].'" method="post">'.
|
|---|
| 162 | '<fieldset><legend>Nastavení týmu</legend>'.
|
|---|
| 163 | '<table><tr><td>Jméno:</td><td><input type="text" name="Name" value="'.htmlspecialchars($Team['Name']).'"/></td></tr>'.
|
|---|
| 164 | '<tr><td>Webové stránky:</td><td>http://<input type="text" name="URL" value="'.htmlspecialchars($Team['URL']).'"/></td></tr>'.
|
|---|
| 165 | '<tr><td>Popis:</td><td><input type="text" name="Description" value="'.htmlspecialchars($Team['Description']).'"/></td></tr>'.
|
|---|
| 166 | '<tr><td colspan="2"><input type="submit" value="'.T('Save').'" /></td></tr>'.
|
|---|
| 167 | '</table></fieldset></form>';
|
|---|
| 168 | } else $Output = ShowMessage('Tým nenalezen.', MESSAGE_CRITICAL);
|
|---|
| 169 | } else $Output = ShowMessage('Nezadáno id týmu', MESSAGE_CRITICAL);
|
|---|
| 170 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 171 | return $Output;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | function TeamModifyFinish()
|
|---|
| 175 | {
|
|---|
| 176 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 177 | $Output = '';
|
|---|
| 178 | if ($User->Licence(LICENCE_USER))
|
|---|
| 179 | {
|
|---|
| 180 | if (array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST))
|
|---|
| 181 | {
|
|---|
| 182 | $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);
|
|---|
| 183 | if ($DbResult->num_rows > 0)
|
|---|
| 184 | {
|
|---|
| 185 | $Team = $DbResult->fetch_assoc();
|
|---|
| 186 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"');
|
|---|
| 187 | $DbRow = $DbResult->fetch_row();
|
|---|
| 188 | $Count = $DbRow[0];
|
|---|
| 189 | if (($Count == 0) and ($_POST['Name'] != ''))
|
|---|
| 190 | {
|
|---|
| 191 | $this->Database->query('UPDATE `Team` SET `Name`="'.$_POST['Name'].'", `Description`="'.$_POST['Description'].'", `URL`="'.$_POST['URL'].'" WHERE Id='.$Team['Id']);
|
|---|
| 192 | $Output .= ShowMessage('Nastavení týmu uloženo.');
|
|---|
| 193 | $this->System->ModuleManager->Modules['Log']->WriteLog('Překladatelský tým upraven '.$_POST['Name'], LOG_TYPE_USER);
|
|---|
| 194 | } else $Output .= ShowMessage('Již existuje tým se stejným jménem.', MESSAGE_CRITICAL);
|
|---|
| 195 | } else $Output .= ShowMessage('Tým nenalezen nebo nemáte oprávnění.', MESSAGE_CRITICAL);
|
|---|
| 196 | } else $Output .= ShowMessage('Nezadáno id týmu nebo některé položky formuláře.', MESSAGE_CRITICAL);
|
|---|
| 197 | } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 198 | $Output .= $this->ShowTeamList();
|
|---|
| 199 | return $Output;
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | function TeamCreate()
|
|---|
| 203 | {
|
|---|
| 204 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 205 | if ($User->Licence(LICENCE_USER))
|
|---|
| 206 | {
|
|---|
| 207 | $Output ='<form action="?action=finish_create" method="post">'.
|
|---|
| 208 | '<fieldset><legend>Vytvoření nového týmu</legend>'.
|
|---|
| 209 | '<table><tr><td>Jméno:</td><td><input type="text" name="Name" /></td></tr>'.
|
|---|
| 210 | '<tr><td>Webové stránky:</td><td>http://<input type="text" name="URL" value=""/></td></tr>'.
|
|---|
| 211 | '<tr><td>Popis:</td><td><input type="text" name="Description" /></td></tr>'.
|
|---|
| 212 | '<tr><td colspan="2"><input type="submit" value="Vytvořit a vstoupit" /></td></tr>'.
|
|---|
| 213 | '</table></fieldset></form>';
|
|---|
| 214 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 215 | return $Output;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | function TeamShow()
|
|---|
| 219 | {
|
|---|
| 220 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 221 | $Output = '';
|
|---|
| 222 | if (array_key_exists('id', $_GET) and is_numeric($_GET['id']))
|
|---|
| 223 | {
|
|---|
| 224 | $DbResult = $this->Database->query('SELECT `Id`, `Name`, `Description`, `URL`, `Leader`, '.
|
|---|
| 225 | '(SELECT COUNT(*) FROM `User` WHERE '.
|
|---|
| 226 | '`Team` = `Team`.`Id`) AS `NumberUser`, '.
|
|---|
| 227 | '(SELECT SUM(`TranslatedCount`) FROM `User` WHERE `Team` = `Team`.`Id`) AS `NumberTranslate`, '.
|
|---|
| 228 | '(SELECT ROUND(AVG(`XP`)) FROM `User` WHERE `Team` = `Team`.`Id`) AS `AverageXP` FROM '.
|
|---|
| 229 | '`Team` WHERE `Id`='.($_GET['id'] * 1));
|
|---|
| 230 | if ($DbResult->num_rows > 0)
|
|---|
| 231 | {
|
|---|
| 232 | $Team = $DbResult->fetch_assoc();
|
|---|
| 233 | $DbResult2 = $this->Database->query('SELECT `Name`, `Id` FROM `User` WHERE `ID`='.$Team['Leader']);
|
|---|
| 234 | if ($DbResult2->num_rows > 0)
|
|---|
| 235 | {
|
|---|
| 236 | $Leader = $DbResult2->fetch_assoc();
|
|---|
| 237 | } else $Leader = array('Name' => '', 'Id' => 0);
|
|---|
| 238 |
|
|---|
| 239 | $Output .='<h3>'.T('Translation team').' '.htmlspecialchars($Team['Name']).'</h3><br />'.
|
|---|
| 240 | T('Web pages').': <a href="http://'.htmlspecialchars($Team['URL']).'">'.htmlspecialchars($Team['URL']).'</a><br/>'.
|
|---|
| 241 | T('Leader').': <a href="'.$this->System->Link('/user/?user='.$Leader['Id']).'">'.$Leader['Name'].'</a><br/>';
|
|---|
| 242 | if ($Team['Description'] != '')
|
|---|
| 243 | $Output .= T('Description').': '.htmlspecialchars($Team['Description']).'<br />';
|
|---|
| 244 | $Output .= '<br />';
|
|---|
| 245 | //$Output .= '<a href="export/?team='.$Team['Id'].'">Exportovat překlad týmu</a> ';
|
|---|
| 246 | if ($User->Licence(LICENCE_USER))
|
|---|
| 247 | $Output .='<a href="?action=gointeam&id='.$Team['Id'].'">'.T('Enter to team').'</a><br /><br />';
|
|---|
| 248 | $XP = GetLevelMinMax($Team['AverageXP']);
|
|---|
| 249 | $Output .='<fieldset><legend>'.T('Statistics').'</legend>'.
|
|---|
| 250 | T('Team member count').': <a href="'.$this->System->Link('/users/?team='.$Team['Id']).'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a><br />'.
|
|---|
| 251 | T('Team number of translated texts').': <strong>'.$Team['NumberTranslate'].'</strong><br />'.
|
|---|
| 252 | T('Average level of team members').': <strong>'.$XP['Level'].'</strong> '.T('experience').': '.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'<br />'.
|
|---|
| 253 | '<br />'.
|
|---|
| 254 | '<strong>'.T('Team completion state for version').' '.Core::Cast($this->System)->Config['Web']['GameVersion'].'</strong><br />';
|
|---|
| 255 |
|
|---|
| 256 | $BuildNumber = GetBuildNumber(Core::Cast($this->System)->Config['Web']['GameVersion']);
|
|---|
| 257 |
|
|---|
| 258 | $GroupListQuery = 'SELECT `Group`.* FROM `Group`';
|
|---|
| 259 | $Query = '';
|
|---|
| 260 | $DbResult = $this->Database->query($GroupListQuery);
|
|---|
| 261 | if ($DbResult->num_rows > 0)
|
|---|
| 262 | {
|
|---|
| 263 | while ($DbRow = $DbResult->fetch_assoc())
|
|---|
| 264 | {
|
|---|
| 265 | $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
|
|---|
| 266 | 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
|
|---|
| 267 | 'WHERE (`User` IN (SELECT `ID` FROM `User` WHERE `Team` = '.$Team['Id'].')) '.
|
|---|
| 268 | 'AND (`Complete` = 1) AND (`T`.`Language`!='.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
|
|---|
| 269 | 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
|
|---|
| 270 | ') AS `C1`) AS `Translated`, '.
|
|---|
| 271 | '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
|
|---|
| 272 | 'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
|
|---|
| 273 | 'WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
|
|---|
| 274 | 'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
|
|---|
| 275 | ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION ';
|
|---|
| 276 | }
|
|---|
| 277 | $Query = substr($Query, 0, - 6);
|
|---|
| 278 |
|
|---|
| 279 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$GroupListQuery.') AS `T`');
|
|---|
| 280 | $DbRow = $DbResult->fetch_row();
|
|---|
| 281 | $PageList = GetPageList($DbRow[0]);
|
|---|
| 282 | $Output .= $PageList['Output'];
|
|---|
| 283 |
|
|---|
| 284 | $Output .='<table class="BaseTable">';
|
|---|
| 285 | $TableColumns = array(
|
|---|
| 286 | array('Name' => 'Name', 'Title' => T('Name')),
|
|---|
| 287 | array('Name' => 'Translated', 'Title' => T('Translated')),
|
|---|
| 288 | array('Name' => 'Total', 'Title' => T('Original')),
|
|---|
| 289 | array('Name' => 'Percent', 'Title' => T('Percent')),
|
|---|
| 290 | );
|
|---|
| 291 |
|
|---|
| 292 | $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
|
|---|
| 293 | $Output .= $Order['Output'];
|
|---|
| 294 |
|
|---|
| 295 | $Translated = 0;
|
|---|
| 296 | $Total = 0;
|
|---|
| 297 | $DbResult = $this->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.$Query.') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']);
|
|---|
| 298 | while ($Group = $DbResult->fetch_assoc())
|
|---|
| 299 | {
|
|---|
| 300 | $Output .='<tr><td>'.T($Group['Name']).'</td><td>'.$Group['Translated'].
|
|---|
| 301 | '</td><td>'.$Group['Total'].'</td><td>'.ProgressBar(150, $Group['Percent']).'</td></tr>';
|
|---|
| 302 | $Translated += $Group['Translated'];
|
|---|
| 303 | $Total += $Group['Total'];
|
|---|
| 304 | }
|
|---|
| 305 | if ($Total > 0) $Progress = round($Translated / $Total * 100, 2);
|
|---|
| 306 | else $Progress = 0;
|
|---|
| 307 | $Output .='<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.
|
|---|
| 308 | $Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.
|
|---|
| 309 | ProgressBar(150, $Progress).'</strong></td></tr>';
|
|---|
| 310 | $Output .='</table>';
|
|---|
| 311 | }
|
|---|
| 312 | $Output .='</fieldset>';
|
|---|
| 313 | } else $Output .= ShowMessage('Tým nenalezen', MESSAGE_CRITICAL);
|
|---|
| 314 | } else $Output .= ShowMessage('Musíte zadat id týmu', MESSAGE_CRITICAL);
|
|---|
| 315 | return $Output;
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | function TeamLeave()
|
|---|
| 319 | {
|
|---|
| 320 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
|---|
| 321 | if ($User->Licence(LICENCE_USER))
|
|---|
| 322 | {
|
|---|
| 323 | $this->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$User->Id);
|
|---|
| 324 | $Output = ShowMessage(T('You are now not member of any team'));
|
|---|
| 325 | $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel vystoupil z týmu', LOG_TYPE_USER);
|
|---|
| 326 |
|
|---|
| 327 | // Delete all teams without users
|
|---|
| 328 | $this->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');
|
|---|
| 329 |
|
|---|
| 330 | // Set new leader for teams where old leader went to other team
|
|---|
| 331 | $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`);');
|
|---|
| 332 |
|
|---|
| 333 | $Output .= $this->ShowTeamList();
|
|---|
| 334 | } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
|
|---|
| 335 | return $Output;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | function Show(): string
|
|---|
| 339 | {
|
|---|
| 340 | if (array_key_exists('action', $_GET))
|
|---|
| 341 | {
|
|---|
| 342 | if ($_GET['action'] == 'gointeam') $Output = $this->TeamJoin();
|
|---|
| 343 | else if ($_GET['action'] == 'finish_create') $Output = $this->TeamCreateFinish();
|
|---|
| 344 | else if ($_GET['action'] == 'modify') $Output = $this->TeamModify();
|
|---|
| 345 | else if ($_GET['action'] == 'finish_modify') $Output = $this->TeamModifyFinish();
|
|---|
| 346 | else if ($_GET['action'] == 'create') $Output = $this->TeamCreate();
|
|---|
| 347 | else if ($_GET['action'] == 'team') $Output = $this->TeamShow();
|
|---|
| 348 | else if ($_GET['action'] == 'leave') $Output = $this->TeamLeave();
|
|---|
| 349 | else $Output = $this->ShowTeamList();
|
|---|
| 350 | } else $Output = $this->ShowTeamList();
|
|---|
| 351 | return $Output;
|
|---|
| 352 | }
|
|---|
| 353 | }
|
|---|