Changeset 376 for trunk/export/index.php


Ignore:
Timestamp:
Mar 11, 2010, 8:40:32 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Informace o přihlášeném uživateli nově pročištěny a sjednoceny do třídy User. SQL pro kontrolu a generovány hesel dostupné přímo přes metodu CryptPasswordSQL. Přístup k Id přihlášeného uživatele přes globální proměnnou $User a vlastnost Id ($User->Id). Podobně přístup k dalším vlastnostem uživatele.
  • Opraveno: Některé chyby z předchozích předělávek.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/export/index.php

    r366 r376  
    66function ExportList()
    77{
    8   global $Database;
     8  global $Database, $User;
    99 
    1010  echo('<a href="?Action=ViewList">Všechny</a>');
    11   if(Licence(LICENCE_USER))
     11  if($User->Licence(LICENCE_USER))
    1212  {
    1313    echo(' <a href="?Action=ViewList&amp;Filter=Others">Ostatních</a>');
     
    1818  if(array_key_exists('Filter', $_GET))
    1919  {
    20     if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$_SESSION['UserID'];
    21     if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$_SESSION['UserID'];
     20    if($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$User->Id;
     21    if($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$User->Id;
    2222  }
    2323 
     
    4646  {
    4747    $Action = '<a href="?Action=View&amp;ExportId='.$Export['Id'].'">Zobrazit</a> <a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=6">Exportovat</a>';
    48     if($Export['User'] == $_SESSION['UserID']) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';
     48    if($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';
    4949    echo('<tr><td>'.HumanDate($Export['TimeCreate']).'</td><td>'.$Export['UserName'].'</td><td>'.$Export['Title'].'</td><td>'.$Export['UsedCount'].'</td><td>'.$Export['UserCount'].'</td><td>'.$Export['GroupCount'].'</td><td>'.$Action.'</td></tr>');
    5050  }
     
    5252  echo($PageList['Output']);
    5353   
    54   if(Licence(LICENCE_USER)) echo('<br/><div style="text-align: center;"><a href="?Action=Create">Vytvořit nový export</a></div>');
     54  if($User->Licence(LICENCE_USER)) echo('<br/><div style="text-align: center;"><a href="?Action=Create">Vytvořit nový export</a></div>');
    5555}
    5656
    5757function ExportCreate()
    5858{
    59   global $Database, $Config;
    60  
    61   if(Licence(LICENCE_USER))
     59  global $Database, $Config, $User;
     60 
     61  if($User->Licence(LICENCE_USER))
    6262  {   
    63     $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM Export WHERE User='.$_SESSION['UserID']);
     63    $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    6464    $DbRow = mysql_fetch_row($DbResult);
    6565    if($DbRow[0] < $Config['MaxExportPerUser'])
     
    7777function ExportCreateFinish()
    7878{
    79   global $Database, $Config;
    80  
    81   if(Licence(LICENCE_USER))
     79  global $Database, $Config, $User;
     80 
     81  if($User->Licence(LICENCE_USER))
    8282  {   
    8383    if(array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
    8484    {
    85       $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Export` WHERE `User`='.$_SESSION['UserID']);
     85      $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    8686      $DbRow = mysql_fetch_row($DbResult);
    8787      if($DbRow[0] < $Config['MaxExportPerUser'])
    8888      {
    89         $Database->SQLCommand('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$_SESSION['UserID'].', NOW(), 1, "'.$_POST['Description'].'")');
     89        $Database->SQLCommand('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
    9090        $ExportId = mysql_insert_id();
    9191        echo('Nový export vytvořen.<br/>Přímý odkaz na tento export: <a href="?Action=View&amp;ExportId='.$ExportId.'">zde</a><br/><br/>');
     
    100100function ExportDelete()
    101101{
    102   global $Database;
    103  
    104   if(Licence(LICENCE_USER))
     102  global $Database, $User;
     103 
     104  if($User->Licence(LICENCE_USER))
    105105  {   
    106106    if(array_key_exists('ExportId', $_GET))
    107107    {
    108       $DbResult = $Database->SQLCommand('SELECT * FROM Export WHERE Id='.$_GET['ExportId'].' AND User='.$_SESSION['UserID']);
     108      $DbResult = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId'].' AND `User`='.$User->Id);
    109109      if(mysql_num_rows($DbResult) > 0)
    110110      {
    111         $Database->SQLCommand('DELETE FROM Export WHERE Id='.$_GET['ExportId']);
     111        $Database->SQLCommand('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    112112        DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
    113113        echo('Export smazán.<br/><br/>');
     
    122122function ExportViewTranslators()
    123123{
    124   global $Database, $TranslationTree, $Config;
     124  global $Database, $TranslationTree, $Config, $User;
    125125
    126126  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    131131    {   
    132132      $Export = mysql_fetch_assoc($DbRows);
    133       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     133      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    134134        else $Editable = false;
    135135       
     
    204204  $Database->SQLCommand('SET @I = 0');
    205205  $DbResult = $Database->SQLCommand($Query);
    206   while($User = mysql_fetch_assoc($DbResult))
    207   {
    208     $Checked = $User['Sequence'] != '';
    209     $Selection = CheckBox('sel'.$User['ID'], $Checked, '', 'CheckBox', !$Editable);
    210     $Sequence = '<input type="text" name="seq'.$User['ID'].'" style="text-align: center; width: 40px;" value="'.$User['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
     206  while($UserLine = mysql_fetch_assoc($DbResult))
     207  {
     208    $Checked = $UserLine['Sequence'] != '';
     209    $Selection = CheckBox('sel'.$UserLine['ID'], $Checked, '', 'CheckBox', !$Editable);
     210    $Sequence = '<input type="text" name="seq'.$UserLine['ID'].'" style="text-align: center; width: 40px;" value="'.$UserLine['Sequence2'].'"'.$DisabledInput[$Editable].'/>';
    211211    echo('<tr>
    212     <td><a href="'.$Config['Web']['BaseURL'].'/TranslationList.php?user='.$User['ID'].'&amp;action=userall" title="Zobrazit všechny jeho přeložené texty">'.$User['Name'].'</a></td>
    213     <td>'.$User['TranslatedCount'].'</td>
    214       <td><img src="'.$Config['Web']['TempFolder'].'/user/'.$User['Name'].'/level.png" alt="Úroveň uživatele" /></td>
     212    <td><a href="'.$Config['Web']['BaseURL'].'/TranslationList.php?user='.$UserLine['ID'].'&amp;action=userall" title="Zobrazit všechny jeho přeložené texty">'.$UserLine['Name'].'</a></td>
     213    <td>'.$UserLine['TranslatedCount'].'</td>
     214      <td><img src="'.$Config['Web']['TempFolder'].'/user/'.$UserLine['Name'].'/level.png" alt="Úroveň uživatele" /></td>
    215215    <td>'.$Selection.'</td><td>'.$Sequence.'</td></tr>');
    216216  }
     
    224224function ExportViewGeneral()
    225225{
    226   global $Database;
     226  global $Database, $User;
    227227 
    228228  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    235235    {   
    236236      $Export = mysql_fetch_assoc($DbRows);
    237       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     237      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    238238        else $Editable = false;
    239239      if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
     
    264264function ExportViewLanguages()
    265265{
    266   global $Database, $TranslationTree, $Config;
     266  global $Database, $TranslationTree, $Config, $User;
    267267
    268268  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    273273    {   
    274274      $Export = mysql_fetch_assoc($DbRows);
    275       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     275      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    276276        else $Editable = false;
    277277       
     
    357357function ExportViewGroups()
    358358{
    359   global $Database, $TranslationTree, $Config;
     359  global $Database, $TranslationTree, $Config, $User;
    360360
    361361  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    366366    {   
    367367      $Export = mysql_fetch_assoc($DbRows);
    368       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     368      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    369369        else $Editable = false;
    370370       
     
    446446function ExportViewOutputFormat()
    447447{
    448   global $Database;
     448  global $Database, $User;
    449449 
    450450  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    455455    {   
    456456      $Export = mysql_fetch_assoc($DbRows);
    457       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     457      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    458458        else $Editable = false;
    459459 
     
    485485function ExportViewVersion()
    486486{
    487   global $Database, $Config;
     487  global $Database, $Config, $User;
    488488
    489489  $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    494494    {   
    495495      $Export = mysql_fetch_assoc($DbRows);
    496       if(Licence(LICENCE_USER) and ($_SESSION['UserID'] == $Export['User'])) $Editable = true;
     496      if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    497497        else $Editable = false;
    498498       
     
    572572  $Export = mysql_fetch_assoc($DbResult);
    573573  $DbResult = $Database->SQLCommand('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
    574   $User = mysql_fetch_assoc($DbResult);
    575   echo('Export <strong><a href="?Action=View&amp;Tab=6&amp;ExportId='.$Export['Id'].'">'.$_GET['ExportId'].'</a></strong> překladatele <strong>'.$User['Name'].'</strong> s označením <strong>'.$Export['Title'].'</strong>');
     574  $UserLine = mysql_fetch_assoc($DbResult);
     575  echo('Export <strong><a href="?Action=View&amp;Tab=6&amp;ExportId='.$Export['Id'].'">'.$_GET['ExportId'].'</a></strong> překladatele <strong>'.$UserLine['Name'].'</strong> s označením <strong>'.$Export['Title'].'</strong>');
    576576  ShowTabs(array('Obecné', 'Překladatelé', 'Překlady', 'Jazyky', 'Formát', 'Verze', 'Výstup'));
    577577  echo('<div id="content">');
Note: See TracChangeset for help on using the changeset viewer.