Changeset 880 for trunk/Modules/Team
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Team/Team.php
r851 r880 24 24 'Icon' => '', 25 25 ), 1); 26 if (array_key_exists('Search', $this->System->ModuleManager->Modules))26 if (array_key_exists('Search', $this->System->ModuleManager->Modules)) 27 27 $this->System->ModuleManager->Modules['Search']->RegisterSearch('team', 28 28 T('Teams'), array('Name'), '`Team`', $this->System->Link('/team/?search=')); … … 38 38 $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/>'; 39 39 40 if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];41 else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';40 if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search']; 41 else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = ''; 42 42 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = ''; 43 43 44 if ($this->System->User->Licence(LICENCE_USER))44 if ($this->System->User->Licence(LICENCE_USER)) 45 45 $Output .= '<br /><div style="text-align: center;"><a href="?action=create">'.T('Create translating team').'</a></div><br/>'; 46 if ($_SESSION['search'] != '')46 if ($_SESSION['search'] != '') 47 47 { 48 48 $SearchQuery = ' AND ((`Name` LIKE "%'.$_SESSION['search'].'%") OR (`Description` LIKE "%'.$_SESSION['search'].'%"))'; … … 64 64 array('Name' => 'TimeCreate', 'Title' => T('Founding date')), 65 65 ); 66 if ($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('User actions'));66 if ($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('User actions')); 67 67 68 68 $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1); … … 72 72 '(SELECT `Name` FROM `User` WHERE `User`.`ID`=`Team`.`Leader`) AS `LeaderName` '. 73 73 'FROM `Team` WHERE 1'.$SearchQuery.$Order['SQL'].$PageList['SQLLimit']); 74 while ($Team = $DbResult->fetch_assoc())74 while ($Team = $DbResult->fetch_assoc()) 75 75 { 76 76 $Output .= '<tr>'. … … 80 80 '<td><a href="'.$this->System->Link('/users/?team='.$Team['Id']).'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a></td>'. 81 81 '<td>'.HumanDate($Team['TimeCreate']).'</td>'; 82 if ($this->System->User->Licence(LICENCE_USER))83 { 84 if ($Team['Leader'] == $this->System->User->Id) $Action = ' <a href="?action=modify&id='.$Team['Id'].'">'.T('Edit').'</a>';82 if ($this->System->User->Licence(LICENCE_USER)) 83 { 84 if ($Team['Leader'] == $this->System->User->Id) $Action = ' <a href="?action=modify&id='.$Team['Id'].'">'.T('Edit').'</a>'; 85 85 else $Action = ''; 86 if ($Team['Id'] == $this->System->User->Team) $Action = ' <a href="?action=leave">'.T('Leave').'</a>';86 if ($Team['Id'] == $this->System->User->Team) $Action = ' <a href="?action=leave">'.T('Leave').'</a>'; 87 87 $Output .= '<td><a href="?action=gointeam&id='.$Team['Id'].'">'.T('Enter').'</a>'.$Action.'</td>'; 88 88 } … … 92 92 $PageList['Output']; 93 93 94 return ($Output);94 return $Output; 95 95 } 96 96 97 97 function TeamJoin() 98 98 { 99 if ($this->System->User->Licence(LICENCE_USER))100 { 101 if (array_key_exists('id', $_GET))99 if ($this->System->User->Licence(LICENCE_USER)) 100 { 101 if (array_key_exists('id', $_GET)) 102 102 { 103 103 $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$this->System->User->Id); … … 114 114 } else $Output = ShowMessage('Nutno zadat id týmu.', MESSAGE_CRITICAL); 115 115 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 116 return ($Output);116 return $Output; 117 117 } 118 118 … … 120 120 { 121 121 $Output = ''; 122 if ($this->System->User->Licence(LICENCE_USER))123 { 124 if (array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST))122 if ($this->System->User->Licence(LICENCE_USER)) 123 { 124 if (array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST)) 125 125 { 126 126 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"'); 127 127 $DbRow = $DbResult->fetch_row(); 128 128 $Count = $DbRow[0]; 129 if (($Count == 0) and ($_POST['Name'] != ''))129 if (($Count == 0) and ($_POST['Name'] != '')) 130 130 { 131 131 $this->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'. … … 142 142 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 143 143 $Output .= $this->ShowTeamList(); 144 return ($Output);144 return $Output; 145 145 } 146 146 147 147 function TeamModify() 148 148 { 149 if ($this->System->User->Licence(LICENCE_USER))150 { 151 if (array_key_exists('id', $_GET))149 if ($this->System->User->Licence(LICENCE_USER)) 150 { 151 if (array_key_exists('id', $_GET)) 152 152 { 153 153 $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$this->System->User->Id); 154 if ($DbResult->num_rows > 0)154 if ($DbResult->num_rows > 0) 155 155 { 156 156 $Team = $DbResult->fetch_assoc(); … … 165 165 } else $Output = ShowMessage('Nezadáno id týmu', MESSAGE_CRITICAL); 166 166 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 167 return ($Output);167 return $Output; 168 168 } 169 169 … … 171 171 { 172 172 $Output = ''; 173 if ($this->System->User->Licence(LICENCE_USER))174 { 175 if (array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST))173 if ($this->System->User->Licence(LICENCE_USER)) 174 { 175 if (array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST)) 176 176 { 177 177 $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$this->System->User->Id); 178 if ($DbResult->num_rows > 0)178 if ($DbResult->num_rows > 0) 179 179 { 180 180 $Team = $DbResult->fetch_assoc(); … … 182 182 $DbRow = $DbResult->fetch_row(); 183 183 $Count = $DbRow[0]; 184 if (($Count == 0) and ($_POST['Name'] != ''))184 if (($Count == 0) and ($_POST['Name'] != '')) 185 185 { 186 186 $this->Database->query('UPDATE `Team` SET `Name`="'.$_POST['Name'].'", `Description`="'.$_POST['Description'].'", `URL`="'.$_POST['URL'].'" WHERE Id='.$Team['Id']); … … 192 192 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 193 193 $Output .= $this->ShowTeamList(); 194 return ($Output);194 return $Output; 195 195 } 196 196 197 197 function TeamCreate() 198 198 { 199 if ($this->System->User->Licence(LICENCE_USER))199 if ($this->System->User->Licence(LICENCE_USER)) 200 200 { 201 201 $Output ='<form action="?action=finish_create" method="post">'. … … 207 207 '</table></fieldset></form>'; 208 208 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 209 return ($Output);209 return $Output; 210 210 } 211 211 … … 213 213 { 214 214 $Output = ''; 215 if (array_key_exists('id', $_GET) and is_numeric($_GET['id']))215 if (array_key_exists('id', $_GET) and is_numeric($_GET['id'])) 216 216 { 217 217 $DbResult = $this->Database->query('SELECT `Id`, `Name`, `Description`, `URL`, `Leader`, '. … … 221 221 '(SELECT ROUND(AVG(`XP`)) FROM `User` WHERE `Team` = `Team`.`Id`) AS `AverageXP` FROM '. 222 222 '`Team` WHERE `Id`='.($_GET['id'] * 1)); 223 if ($DbResult->num_rows > 0)223 if ($DbResult->num_rows > 0) 224 224 { 225 225 $Team = $DbResult->fetch_assoc(); 226 226 $DbResult2 = $this->Database->query('SELECT `Name`, `Id` FROM `User` WHERE `ID`='.$Team['Leader']); 227 if ($DbResult2->num_rows > 0)227 if ($DbResult2->num_rows > 0) 228 228 { 229 229 $Leader = $DbResult2->fetch_assoc(); … … 233 233 T('Web pages').': <a href="http://'.htmlspecialchars($Team['URL']).'">'.htmlspecialchars($Team['URL']).'</a><br/>'. 234 234 T('Leader').': <a href="'.$this->System->Link('/user/?user='.$Leader['Id']).'">'.$Leader['Name'].'</a><br/>'; 235 if ($Team['Description'] != '')235 if ($Team['Description'] != '') 236 236 $Output .= T('Description').': '.htmlspecialchars($Team['Description']).'<br />'; 237 237 $Output .= '<br />'; 238 238 //$Output .= '<a href="export/?team='.$Team['Id'].'">Exportovat překlad týmu</a> '; 239 if ($this->System->User->Licence(LICENCE_USER))239 if ($this->System->User->Licence(LICENCE_USER)) 240 240 $Output .='<a href="?action=gointeam&id='.$Team['Id'].'">'.T('Enter to team').'</a><br /><br />'; 241 241 $XP = GetLevelMinMax($Team['AverageXP']); … … 252 252 $Query = ''; 253 253 $DbResult = $this->Database->query($GroupListQuery); 254 if ($DbResult->num_rows > 0)255 { 256 while ($DbRow = $DbResult->fetch_assoc())254 if ($DbResult->num_rows > 0) 255 { 256 while ($DbRow = $DbResult->fetch_assoc()) 257 257 { 258 258 $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('. … … 289 289 $Total = 0; 290 290 $DbResult = $this->Database->query('SELECT *, ROUND(`Translated` / `Total` * 100, 2) AS `Percent` FROM ('.$Query.') AS `C3` '.$Order['SQL'].$PageList['SQLLimit']); 291 while ($Group = $DbResult->fetch_assoc())291 while ($Group = $DbResult->fetch_assoc()) 292 292 { 293 293 $Output .='<tr><td>'.T($Group['Name']).'</td><td>'.$Group['Translated']. … … 296 296 $Total += $Group['Total']; 297 297 } 298 if ($Total > 0) $Progress = round($Translated / $Total * 100, 2);298 if ($Total > 0) $Progress = round($Translated / $Total * 100, 2); 299 299 else $Progress = 0; 300 300 $Output .='<tr><td><strong>'.T('Total').'</strong></td><td><strong>'. … … 306 306 } else $Output .= ShowMessage('Tým nenalezen', MESSAGE_CRITICAL); 307 307 } else $Output .= ShowMessage('Musíte zadat id týmu', MESSAGE_CRITICAL); 308 return ($Output);308 return $Output; 309 309 } 310 310 311 311 function TeamLeave() 312 312 { 313 if ($this->System->User->Licence(LICENCE_USER))313 if ($this->System->User->Licence(LICENCE_USER)) 314 314 { 315 315 $this->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$this->System->User->Id); … … 325 325 $Output .= $this->ShowTeamList(); 326 326 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 327 return ($Output);327 return $Output; 328 328 } 329 329 330 330 function Show() 331 331 { 332 if (array_key_exists('action', $_GET))333 { 334 if ($_GET['action'] == 'gointeam') $Output = $this->TeamJoin();335 else if ($_GET['action'] == 'finish_create') $Output = $this->TeamCreateFinish();336 else if ($_GET['action'] == 'modify') $Output = $this->TeamModify();337 else if ($_GET['action'] == 'finish_modify') $Output = $this->TeamModifyFinish();338 else if ($_GET['action'] == 'create') $Output = $this->TeamCreate();339 else if ($_GET['action'] == 'team') $Output = $this->TeamShow();340 else if ($_GET['action'] == 'leave') $Output = $this->TeamLeave();332 if (array_key_exists('action', $_GET)) 333 { 334 if ($_GET['action'] == 'gointeam') $Output = $this->TeamJoin(); 335 else if ($_GET['action'] == 'finish_create') $Output = $this->TeamCreateFinish(); 336 else if ($_GET['action'] == 'modify') $Output = $this->TeamModify(); 337 else if ($_GET['action'] == 'finish_modify') $Output = $this->TeamModifyFinish(); 338 else if ($_GET['action'] == 'create') $Output = $this->TeamCreate(); 339 else if ($_GET['action'] == 'team') $Output = $this->TeamShow(); 340 else if ($_GET['action'] == 'leave') $Output = $this->TeamLeave(); 341 341 else $Output = $this->ShowTeamList(); 342 342 } else $Output = $this->ShowTeamList(); 343 return ($Output);343 return $Output; 344 344 } 345 345 }
Note:
See TracChangeset
for help on using the changeset viewer.