Changeset 893 for trunk/Modules/Team


Ignore:
Timestamp:
Mar 6, 2023, 1:48:45 AM (22 months ago)
Author:
chronos
Message:
  • Fixed: Class types casting for better type checking.
  • Fixed: XML direct export.
  • Modified: User class instance moved from Core class to ModuleUser class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Team/Team.php

    r888 r893  
    3434  function ShowTeamList()
    3535  {
     36    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    3637    $this->Title = T('Teams');
    3738    $Output = '<h3>'.T('List of translating teams').'</h3>';
     
    4243    if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
    4344
    44     if ($this->System->User->Licence(LICENCE_USER))
     45    if ($User->Licence(LICENCE_USER))
    4546      $Output .= '<br /><div style="text-align: center;"><a href="?action=create">'.T('Create translating team').'</a></div><br/>';
    4647    if ($_SESSION['search'] != '')
     
    6465      array('Name' => 'TimeCreate', 'Title' => T('Founding date')),
    6566    );
    66     if ($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('User actions'));
     67    if ($User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('User actions'));
    6768
    6869    $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1);
     
    8081        '<td><a href="'.$this->System->Link('/users/?team='.$Team['Id']).'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a></td>'.
    8182        '<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&amp;id='.$Team['Id'].'">'.T('Edit').'</a>';
     83      if ($User->Licence(LICENCE_USER))
     84      {
     85        if ($Team['Leader'] == $User->Id) $Action = ' <a href="?action=modify&amp;id='.$Team['Id'].'">'.T('Edit').'</a>';
    8586        else $Action = '';
    86         if ($Team['Id'] == $this->System->User->Team) $Action = ' <a href="?action=leave">'.T('Leave').'</a>';
     87        if ($Team['Id'] == $User->Team) $Action = ' <a href="?action=leave">'.T('Leave').'</a>';
    8788        $Output .= '<td><a href="?action=gointeam&amp;id='.$Team['Id'].'">'.T('Enter').'</a>'.$Action.'</td>';
    8889      }
     
    9798  function TeamJoin()
    9899  {
    99     if ($this->System->User->Licence(LICENCE_USER))
     100    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     101    if ($User->Licence(LICENCE_USER))
    100102    {
    101103      if (array_key_exists('id', $_GET))
    102104      {
    103         $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$this->System->User->Id);
     105        $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$User->Id);
    104106        $Output = ShowMessage(T('You joined new team'));
    105107        $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel vstoupil do týmu '.$_GET['id'], LOG_TYPE_USER);
     
    119121  function TeamCreateFinish()
    120122  {
     123    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    121124    $Output = '';
    122     if ($this->System->User->Licence(LICENCE_USER))
     125    if ($User->Licence(LICENCE_USER))
    123126    {
    124127      if (array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST))
     
    131134          $this->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'.
    132135            ' VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'.
    133             $_POST['URL'].'", NOW(), '.$this->System->User->Id.')');
    134           $this->Database->query('UPDATE `User` SET `Team` = '.$this->Database->insert_id.' WHERE `ID` = '.$this->System->User->Id);
     136            $_POST['URL'].'", NOW(), '.$User->Id.')');
     137          $this->Database->query('UPDATE `User` SET `Team` = '.$this->Database->insert_id.' WHERE `ID` = '.$User->Id);
    135138          $Output .= ShowMessage('Překladatelský tým vytvořen.');
    136139          $this->System->ModuleManager->Modules['Log']->WriteLog('Překladatelský tým vytvořen '.$_POST['Name'], LOG_TYPE_USER);
     
    147150  function TeamModify()
    148151  {
    149     if ($this->System->User->Licence(LICENCE_USER))
     152    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     153    if ($User->Licence(LICENCE_USER))
    150154    {
    151155      if (array_key_exists('id', $_GET))
    152156      {
    153         $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$this->System->User->Id);
     157        $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);
    154158        if ($DbResult->num_rows > 0)
    155159        {
     
    170174  function TeamModifyFinish()
    171175  {
     176    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    172177    $Output = '';
    173     if ($this->System->User->Licence(LICENCE_USER))
     178    if ($User->Licence(LICENCE_USER))
    174179    {
    175180      if (array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST))
    176181      {
    177         $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$this->System->User->Id);
     182        $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);
    178183        if ($DbResult->num_rows > 0)
    179184        {
     
    197202  function TeamCreate()
    198203  {
    199     if ($this->System->User->Licence(LICENCE_USER))
     204    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     205    if ($User->Licence(LICENCE_USER))
    200206    {
    201207      $Output ='<form action="?action=finish_create" method="post">'.
     
    212218  function TeamShow()
    213219  {
     220    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    214221    $Output = '';
    215222    if (array_key_exists('id', $_GET) and is_numeric($_GET['id']))
     
    237244        $Output .= '<br />';
    238245        //$Output .= '<a href="export/?team='.$Team['Id'].'">Exportovat překlad týmu</a> ';
    239         if ($this->System->User->Licence(LICENCE_USER))
     246        if ($User->Licence(LICENCE_USER))
    240247          $Output .='<a href="?action=gointeam&amp;id='.$Team['Id'].'">'.T('Enter to team').'</a><br /><br />';
    241248        $XP = GetLevelMinMax($Team['AverageXP']);
     
    245252          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 />'.
    246253          '<br />'.
    247           '<strong>'.T('Team completion state for version').' '.$this->System->Config['Web']['GameVersion'].'</strong><br />';
    248 
    249         $BuildNumber = GetBuildNumber($this->System->Config['Web']['GameVersion']);
     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']);
    250257
    251258        $GroupListQuery = 'SELECT `Group`.* FROM `Group`';
     
    259266              'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
    260267              'WHERE (`User` IN (SELECT `ID` FROM `User` WHERE `Team` = '.$Team['Id'].')) '.
    261               'AND (`Complete` = 1) AND (`T`.`Language`!='.$this->System->Config['OriginalLanguage'].') '.
     268              'AND (`Complete` = 1) AND (`T`.`Language`!='.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    262269              'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
    263270              ') AS `C1`) AS `Translated`, '.
    264271              '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    265272              'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
    266               'WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     273              'WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    267274              'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
    268275              ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION ';
     
    311318  function TeamLeave()
    312319  {
    313     if ($this->System->User->Licence(LICENCE_USER))
    314     {
    315       $this->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$this->System->User->Id);
     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);
    316324      $Output = ShowMessage(T('You are now not member of any team'));
    317325      $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel vystoupil z týmu', LOG_TYPE_USER);
Note: See TracChangeset for help on using the changeset viewer.