Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

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

    r851 r880  
    2424      'Icon' => '',
    2525    ), 1);
    26     if(array_key_exists('Search', $this->System->ModuleManager->Modules))
     26    if (array_key_exists('Search', $this->System->ModuleManager->Modules))
    2727      $this->System->ModuleManager->Modules['Search']->RegisterSearch('team',
    2828      T('Teams'), array('Name'), '`Team`', $this->System->Link('/team/?search='));
     
    3838    $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/>';
    3939
    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'] = '';
    4242    if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
    4343
    44     if($this->System->User->Licence(LICENCE_USER))
     44    if ($this->System->User->Licence(LICENCE_USER))
    4545      $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'] != '')
    4747    {
    4848      $SearchQuery = ' AND ((`Name` LIKE "%'.$_SESSION['search'].'%") OR (`Description` LIKE "%'.$_SESSION['search'].'%"))';
     
    6464      array('Name' => 'TimeCreate', 'Title' => T('Founding date')),
    6565    );
    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'));
    6767
    6868    $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1);
     
    7272      '(SELECT `Name` FROM `User` WHERE `User`.`ID`=`Team`.`Leader`) AS `LeaderName` '.
    7373      'FROM `Team` WHERE 1'.$SearchQuery.$Order['SQL'].$PageList['SQLLimit']);
    74     while($Team = $DbResult->fetch_assoc())
     74    while ($Team = $DbResult->fetch_assoc())
    7575    {
    7676      $Output .= '<tr>'.
     
    8080        '<td><a href="'.$this->System->Link('/users/?team='.$Team['Id']).'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a></td>'.
    8181        '<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>';
     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>';
    8585        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>';
    8787        $Output .= '<td><a href="?action=gointeam&amp;id='.$Team['Id'].'">'.T('Enter').'</a>'.$Action.'</td>';
    8888      }
     
    9292      $PageList['Output'];
    9393
    94     return($Output);
     94    return $Output;
    9595  }
    9696
    9797  function TeamJoin()
    9898  {
    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))
    102102      {
    103103        $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$this->System->User->Id);
     
    114114      } else $Output = ShowMessage('Nutno zadat id týmu.', MESSAGE_CRITICAL);
    115115    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    116     return($Output);
     116    return $Output;
    117117  }
    118118
     
    120120  {
    121121    $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))
    125125      {
    126126        $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE `Name` = "'.trim($_POST['Name']).'"');
    127127        $DbRow = $DbResult->fetch_row();
    128128        $Count = $DbRow[0];
    129         if(($Count == 0) and ($_POST['Name'] != ''))
     129        if (($Count == 0) and ($_POST['Name'] != ''))
    130130        {
    131131          $this->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'.
     
    142142    } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    143143    $Output .= $this->ShowTeamList();
    144     return($Output);
     144    return $Output;
    145145  }
    146146
    147147  function TeamModify()
    148148  {
    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))
    152152      {
    153153        $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)
    155155        {
    156156          $Team = $DbResult->fetch_assoc();
     
    165165      } else $Output = ShowMessage('Nezadáno id týmu', MESSAGE_CRITICAL);
    166166    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    167     return($Output);
     167    return $Output;
    168168  }
    169169
     
    171171  {
    172172    $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))
    176176      {
    177177        $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)
    179179        {
    180180          $Team = $DbResult->fetch_assoc();
     
    182182          $DbRow = $DbResult->fetch_row();
    183183          $Count = $DbRow[0];
    184           if(($Count == 0) and ($_POST['Name'] != ''))
     184          if (($Count == 0) and ($_POST['Name'] != ''))
    185185          {
    186186            $this->Database->query('UPDATE `Team` SET `Name`="'.$_POST['Name'].'", `Description`="'.$_POST['Description'].'", `URL`="'.$_POST['URL'].'" WHERE Id='.$Team['Id']);
     
    192192    } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    193193    $Output .= $this->ShowTeamList();
    194     return($Output);
     194    return $Output;
    195195  }
    196196
    197197  function TeamCreate()
    198198  {
    199     if($this->System->User->Licence(LICENCE_USER))
     199    if ($this->System->User->Licence(LICENCE_USER))
    200200    {
    201201      $Output ='<form action="?action=finish_create" method="post">'.
     
    207207        '</table></fieldset></form>';
    208208    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    209     return($Output);
     209    return $Output;
    210210  }
    211211
     
    213213  {
    214214    $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']))
    216216    {
    217217      $DbResult = $this->Database->query('SELECT `Id`, `Name`, `Description`, `URL`, `Leader`, '.
     
    221221        '(SELECT ROUND(AVG(`XP`)) FROM `User` WHERE `Team` = `Team`.`Id`) AS `AverageXP` FROM '.
    222222        '`Team` WHERE `Id`='.($_GET['id'] * 1));
    223       if($DbResult->num_rows > 0)
     223      if ($DbResult->num_rows > 0)
    224224      {
    225225        $Team = $DbResult->fetch_assoc();
    226226        $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)
    228228        {
    229229          $Leader = $DbResult2->fetch_assoc();
     
    233233          T('Web pages').': <a href="http://'.htmlspecialchars($Team['URL']).'">'.htmlspecialchars($Team['URL']).'</a><br/>'.
    234234          T('Leader').': <a href="'.$this->System->Link('/user/?user='.$Leader['Id']).'">'.$Leader['Name'].'</a><br/>';
    235         if($Team['Description'] != '')
     235        if ($Team['Description'] != '')
    236236          $Output .= T('Description').': '.htmlspecialchars($Team['Description']).'<br />';
    237237        $Output .= '<br />';
    238238        //$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))
    240240          $Output .='<a href="?action=gointeam&amp;id='.$Team['Id'].'">'.T('Enter to team').'</a><br /><br />';
    241241        $XP = GetLevelMinMax($Team['AverageXP']);
     
    252252        $Query = '';
    253253        $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())
    257257          {
    258258            $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
     
    289289          $Total = 0;
    290290          $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())
    292292          {
    293293            $Output .='<tr><td>'.T($Group['Name']).'</td><td>'.$Group['Translated'].
     
    296296            $Total += $Group['Total'];
    297297          }
    298           if($Total > 0) $Progress = round($Translated / $Total * 100, 2);
     298          if ($Total > 0) $Progress = round($Translated / $Total * 100, 2);
    299299          else $Progress = 0;
    300300          $Output .='<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.
     
    306306      } else $Output .= ShowMessage('Tým nenalezen', MESSAGE_CRITICAL);
    307307    } else $Output .= ShowMessage('Musíte zadat id týmu', MESSAGE_CRITICAL);
    308     return($Output);
     308    return $Output;
    309309  }
    310310
    311311  function TeamLeave()
    312312  {
    313     if($this->System->User->Licence(LICENCE_USER))
     313    if ($this->System->User->Licence(LICENCE_USER))
    314314    {
    315315      $this->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$this->System->User->Id);
     
    325325      $Output .= $this->ShowTeamList();
    326326    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    327     return($Output);
     327    return $Output;
    328328  }
    329329
    330330  function Show()
    331331  {
    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();
    341341      else $Output = $this->ShowTeamList();
    342342    } else $Output = $this->ShowTeamList();
    343     return($Output);
     343    return $Output;
    344344  }
    345345}
Note: See TracChangeset for help on using the changeset viewer.