Changeset 365 for trunk/team.php


Ignore:
Timestamp:
Mar 9, 2010, 11:29:05 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Jména tabulek v databází upraveny na stejná s prvními velkými písmeny.
  • Upraveno: Doplněny SQL uvozovky do mnoha SQL dotazů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/team.php

    r357 r365  
    3131  echo($Order['Output']);
    3232
    33   if(array_key_exists('search', $_GET))  $_SESSION['search'] = ' WHERE `name` LIKE "%'.$_GET['search'].'%" OR `description` LIKE "%'.$_GET['search'].'%"';
     33  if(array_key_exists('search', $_GET))  $_SESSION['search'] = ' WHERE `Name` LIKE "%'.$_GET['search'].'%" OR `Description` LIKE "%'.$_GET['search'].'%"';
    3434    else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
    3535    if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
     
    4646    if(!is_numeric($_SESSION['team'])) echo(' <a href="?Where">Zrušit filtr týmů</a><br />');
    4747    */
    48     $DbResult = $Database->SQLCommand('SELECT `Team` FROM `user` WHERE `ID`='.$_SESSION['UserID']);
     48    $DbResult = $Database->SQLCommand('SELECT `Team` FROM `User` WHERE `ID`='.$_SESSION['UserID']);
    4949    $User = mysql_fetch_assoc($DbResult);   
    5050
    51     $ID = $Database->SQLCommand('SELECT *, (SELECT COUNT(*) FROM `user` WHERE `user`.`team` = `Team`.`Id`) AS `NumberUser`, (SELECT `user` FROM `user` WHERE `user`.`ID`=`Team`.`Leader`) AS `LeaderName` FROM `Team` '.$_SESSION['search'].$Order['SQL'].$PageList['SQLLimit']);
     51    $ID = $Database->SQLCommand('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']);
    5252    while($Team = mysql_fetch_assoc($ID))
    5353    {
     
    8181    if(array_key_exists('id', $_GET))
    8282    {
    83       $Database->SQLCommand('UPDATE `user` SET `team` = '.$_GET['id'].' WHERE `ID` = '.$_SESSION['UserID']);
     83      $Database->SQLCommand('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$_SESSION['UserID']);
    8484      echo('<strong>Vstoupil jsi do týmu</strong><br /><br />');   
    8585      WriteLog('Uživatel vstoupil do týmu '.$_GET['id'], LOG_TYPE_USER);
    8686
    8787      // Delete all teams without users
    88       $Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `user` WHERE `user`.`team` = `Team`.`Id`) = 0');
     88      $Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');
    8989       
    9090      // Set new leader for teams where old leader went to other team
    91       $Database->SQLCommand('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);');
     91      $Database->SQLCommand('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`);');
    9292       
    9393      ShowTeamList();
     
    110110      {
    111111        $Database->SQLCommand('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`,`Leader`) VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'.$_POST['URL'].'", NOW(), '.$_SESSION['UserID'].')'); 
    112         $Database->SQLCommand('UPDATE `user` SET `team` = '.mysql_insert_id().' WHERE `ID` = '.$_SESSION['UserID']);
     112        $Database->SQLCommand('UPDATE `User` SET `Team` = '.mysql_insert_id().' WHERE `ID` = '.$_SESSION['UserID']);
    113113        echo('<strong>Překladatelský tým vytvořen</strong><br /><br />');
    114114        WriteLog('Překladatelský tým vytvořen '.$_POST['Name'], LOG_TYPE_USER);
    115115
    116116        // Delete all teams without users
    117         $Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `user` WHERE `user`.`team` = `Team`.`Id`) = 0');   
     117        $Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');   
    118118      } else echo('Již existuje tým se stejným jménem');
    119119    } else echo('Chybí údaje formuláře');
     
    195195    ImgLevelUpdate();
    196196     
    197     $Team = mysql_fetch_assoc($Database->SQLCommand('SELECT *, (SELECT count(*) FROM `user` WHERE `team` = `Team`.`Id`) AS `NumberUser`, (SELECT SUM(`TranslatedCount`) FROM `user` WHERE `team` = `Team`.`Id`) AS `NumberTranslate` FROM `Team` WHERE `Id`='.$_GET['id']));
    198     $DbResult = $Database->SQLCommand('SELECT user FROM user WHERE ID='.$Team['Leader']);
     197    $Team = mysql_fetch_assoc($Database->SQLCommand('SELECT *, (SELECT COUNT(*) FROM `User` WHERE `Team` = `Team`.`Id`) AS `NumberUser`, (SELECT SUM(`TranslatedCount`) FROM `User` WHERE `team` = `Team`.`Id`) AS `NumberTranslate` FROM `Team` WHERE `Id`='.$_GET['id']));
     198    $DbResult = $Database->SQLCommand('SELECT `Name` FROM `User` WHERE `ID`='.$Team['Leader']);
    199199    if(mysql_num_rows($DbResult) > 0)
    200200    {
    201201      $Leader = mysql_fetch_assoc($DbResult);
    202       $Leader = $Leader['user'];
     202      $Leader = $Leader['Name'];
    203203    } else $Leader = '';
    204204   
     
    227227  if(Licence(LICENCE_USER))
    228228  {   
    229     $Database->SQLCommand('UPDATE `user` SET `team` = 0 WHERE `ID` = '.$_SESSION['UserID']);
     229    $Database->SQLCommand('UPDATE `User` SET `Team` = 0 WHERE `ID` = '.$_SESSION['UserID']);
    230230    echo('<strong>Nyní nejste členem žádného týmu</strong><br /><br />');   
    231231    WriteLog('Uživatel vystoupil z týmu', LOG_TYPE_USER);
    232232
    233233    // Delete all teams without users
    234     $Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `user` WHERE `user`.`team` = `Team`.`Id`) = 0');
     234    $Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');
    235235       
    236236    // Set new leader for teams where old leader went to other team
    237     $Database->SQLCommand('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);');
     237    $Database->SQLCommand('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`);');
    238238       
    239239    ShowTeamList();
Note: See TracChangeset for help on using the changeset viewer.