Changeset 412 for trunk


Ignore:
Timestamp:
Apr 2, 2010, 7:08:00 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Lepší a přehlednější kontrola zadávání id exportu na jednom místě.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/export/index.php

    r411 r412  
    106106  if($User->Licence(LICENCE_USER))
    107107  {   
    108     if(array_key_exists('ExportId', $_GET))
    109     {
    110       $DbResult = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId'].' AND `User`='.$User->Id);
    111       if(mysql_num_rows($DbResult) > 0)
    112       {
    113         $Database->SQLCommand('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    114         DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
    115         echo('Export smazán.<br/><br/>');
    116         $_GET['Filter'] = 'my';
    117         WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT);
    118         ExportList();
    119       } else echo('Export '.$_GET['ExportId'].' nelze smazat.<br/>');
    120     } else echo('Nebylo zadáno Id');
     108    $DbResult = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId'].' AND `User`='.$User->Id);
     109    $Database->SQLCommand('DELETE FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     110    DeleteDirectory('../tmp/Export/'.$_GET['ExportId'].'/');
     111    echo('Export smazán.<br/><br/>');
     112    $_GET['Filter'] = 'my';
     113    WriteLog('Smazán export '.$_GET['ExportId'], LOG_TYPE_EXPORT);
     114    ExportList();
    121115  } else echo('Nemáte oprávnění');
    122116}
     
    127121
    128122  $DisabledInput = array(false => ' disabled="disabled"', true => '');
    129   if(array_key_exists('ExportId', $_GET))
    130   {
    131     $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    132     if(mysql_num_rows($DbRows) > 0)
    133     {   
    134       $Export = mysql_fetch_assoc($DbRows);
    135       if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    136         else $Editable = false;
    137        
     123  $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     124  $Export = mysql_fetch_assoc($DbRows);
     125  if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
     126    else $Editable = false;       
    138127       
    139128  if(array_key_exists('Operation', $_GET))
     
    220209  echo('</form>');
    221210  echo($PageList['Output']);
    222     } else echo('Položka nenalezena');
    223   } else echo('Nebylo zadáno Id');
    224211}
    225212
     
    231218  $DisabledTextArea = array(false => ' readonly="yes"', true => '');
    232219  echo('<h3>Obecná nastavení</h3>');
    233   if(array_key_exists('ExportId', $_GET))
    234   {
    235     $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    236     if(mysql_num_rows($DbRows) > 0)
    237     {   
    238       $Export = mysql_fetch_assoc($DbRows);
    239       if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    240         else $Editable = false;
    241       if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
    242       {
    243         if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1;
    244           else $WithDiacritic = 0;
    245         $Database->SQLCommand('UPDATE `Export` SET `Title`="'.$_POST['Title'].'", `Description`="'.$_POST['Description'].'", `WithDiacritic`='.$WithDiacritic.' WHERE Id='.$Export['Id']);
    246         $Export['Title'] = $_POST['Title'];
    247         $Export['Description'] = $_POST['Description'];
    248         $Export['WithDiacritic'] = $WithDiacritic;
    249       }
     220  $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     221  $Export = mysql_fetch_assoc($DbRows);
     222  if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
     223    else $Editable = false;
     224  if($Editable and array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
     225  {
     226    if(array_key_exists('WithDiacritic', $_POST)) $WithDiacritic = 1;
     227      else $WithDiacritic = 0;
     228    $Database->SQLCommand('UPDATE `Export` SET `Title`="'.$_POST['Title'].'", `Description`="'.$_POST['Description'].'", `WithDiacritic`='.$WithDiacritic.' WHERE Id='.$Export['Id']);
     229    $Export['Title'] = $_POST['Title'];
     230    $Export['Description'] = $_POST['Description'];
     231    $Export['WithDiacritic'] = $WithDiacritic;
     232  }
    250233     
    251       if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"'; else $WithDiacritic = '';
    252       echo('<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
    253         '<table>');
    254       if($Editable)
    255      
    256         echo('<tr><td colspan="2"><input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/></td></tr>');
    257       }
    258       echo('<tr><td>Označení:</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'.
     234  if($Export['WithDiacritic'] == 1) $WithDiacritic = ' checked="checked"'; else $WithDiacritic = '';
     235    echo('<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
     236      '<table>');
     237  if($Editable)
     238 
     239    echo('<tr><td colspan="2"><input type="submit" value="Uložit" '.$DisabledInput[$Editable].'/></td></tr>');
     240  }
     241  echo('<tr><td>Označení:</td><td><input type="text" style="width: 400px" name="Title" value="'.$Export['Title'].'"'.$DisabledInput[$Editable].'/></td></tr>'.
    259242        '<tr><td>Popis:</td><td><textarea name="Description" cols="54" rows="10"'.$DisabledTextArea[$Editable].'>'.$Export['Description'].'</textarea></td></tr>'.
    260243        '<tr><td>Včetně háčků a čárek</td><td><input type="checkbox" name="WithDiacritic" '.$WithDiacritic.''.$DisabledInput[$Editable].'/></td></tr>'.
    261       '</table></form>');
    262     } else echo('Položka nenalezena');
    263   } else echo('Nebylo zadáno Id');
     244  '</table></form>');
    264245}
    265246
     
    269250
    270251  $DisabledInput = array(false => ' disabled="disabled"', true => '');
    271   if(array_key_exists('ExportId', $_GET))
    272   {
    273     $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    274     if(mysql_num_rows($DbRows) > 0)
    275     {   
    276       $Export = mysql_fetch_assoc($DbRows);
    277       if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    278         else $Editable = false;
     252  $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     253  $Export = mysql_fetch_assoc($DbRows);
     254  if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
     255    else $Editable = false;
    279256       
    280257  if(array_key_exists('Operation', $_GET))
     
    353330  echo('</form>');
    354331  echo($PageList['Output']);
    355     } else echo('Položka nenalezena');
    356   } else echo('Nebylo zadáno Id');
    357332}
    358333
     
    362337
    363338  $DisabledInput = array(false => ' disabled="disabled"', true => '');
    364   if(array_key_exists('ExportId', $_GET))
    365   {
    366     $DbRows = $Database->SQLCommand('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
    367     if(mysql_num_rows($DbRows) > 0)
    368     {   
    369       $Export = mysql_fetch_assoc($DbRows);
    370       if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    371         else $Editable = false;
     339  $DbRows = $Database->SQLCommand('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
     340  $Export = mysql_fetch_assoc($DbRows);
     341  if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
     342    else $Editable = false;
    372343       
    373344  if(array_key_exists('Operation', $_GET))
     
    442413  echo('</form>');
    443414  echo($PageList['Output']);
    444     } else echo('Položka nenalezena');
    445   } else echo('Nebylo zadáno Id');
    446415}
    447416
     
    490459
    491460  $DisabledInput = array(false => ' disabled="disabled"', true => '');
    492   if(array_key_exists('ExportId', $_GET))
    493   {
    494     $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    495     if(mysql_num_rows($DbRows) > 0)
    496     {   
    497       $Export = mysql_fetch_assoc($DbRows);
    498       if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    499         else $Editable = false;
     461  $DbRows = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     462  $Export = mysql_fetch_assoc($DbRows);
     463  if($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
     464    else $Editable = false;
    500465       
    501466  if(array_key_exists('ClientVersion', $_POST))
     
    545510  echo('</form>');
    546511  echo($PageList['Output']);
    547     } else echo('Položka nenalezena');
    548   } else echo('Nebylo zadáno Id');
    549512}
    550513
     
    571534  global $Database, $System;
    572535
    573   if(array_key_exists('ExportId', $_GET))
    574   {
    575     $Export = new Export($System);
     536  $Export = new Export($System);
    576537  $Export->Id = $_GET['ExportId'];
    577538  $Export->Init();
     
    625586  echo('<tr><td><strong>Celkem</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Translated / $Total * 100, 2)).'</strong></td></tr>');
    626587  echo('</table>');
     588}
     589
     590function ExportView()
     591{
     592  global $Database;
     593
     594  if(array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
     595  {
     596    $DbResult = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     597    if(mysql_num_rows($DbResult) > 0)
     598    {   
     599      $Export = mysql_fetch_assoc($DbResult);
     600 
     601      $DbResult = $Database->SQLCommand('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
     602      $UserLine = mysql_fetch_assoc($DbResult);
     603      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>');
     604      ShowTabs(array('Obecné', 'Překladatelé', 'Překlady', 'Jazyky', 'Formát', 'Verze', 'Statistika', 'Výstup'));
     605      echo('<div id="content">');
     606      if($_SESSION['Tab'] == 0) ExportViewGeneral();
     607      else if($_SESSION['Tab'] == 1) ExportViewTranslators();
     608      else if($_SESSION['Tab'] == 2) ExportViewGroups();
     609      else if($_SESSION['Tab'] == 3) ExportViewLanguages();
     610      else if($_SESSION['Tab'] == 4) ExportViewOutputFormat();
     611      else if($_SESSION['Tab'] == 5) ExportViewVersion();
     612      else if($_SESSION['Tab'] == 6) ExportViewStat();
     613      else if($_SESSION['Tab'] == 7) ExportViewOutput();
     614      else ExportViewGeneral();
     615 
     616      echo('</div>');
     617    } else echo('Export nenalezen');
    627618  } else echo('Nebylo zadáno Id');
    628 }
    629 
    630 function ExportView()
    631 {
    632   global $Database;
    633 
    634   $DbResult = $Database->SQLCommand('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    635   $Export = mysql_fetch_assoc($DbResult);
    636   $DbResult = $Database->SQLCommand('SELECT * FROM `User` WHERE `ID`='.$Export['User']);
    637   $UserLine = mysql_fetch_assoc($DbResult);
    638   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>');
    639   ShowTabs(array('Obecné', 'Překladatelé', 'Překlady', 'Jazyky', 'Formát', 'Verze', 'Statistika', 'Výstup'));
    640   echo('<div id="content">');
    641   if($_SESSION['Tab'] == 0) ExportViewGeneral();
    642   else if($_SESSION['Tab'] == 1) ExportViewTranslators();
    643   else if($_SESSION['Tab'] == 2) ExportViewGroups();
    644   else if($_SESSION['Tab'] == 3) ExportViewLanguages();
    645   else if($_SESSION['Tab'] == 4) ExportViewOutputFormat();
    646   else if($_SESSION['Tab'] == 5) ExportViewVersion();
    647   else if($_SESSION['Tab'] == 6) ExportViewStat();
    648   else if($_SESSION['Tab'] == 7) ExportViewOutput();
    649  
    650   echo('</div>');
    651619}
    652620
Note: See TracChangeset for help on using the changeset viewer.