Changeset 427 for trunk/save.php
- Timestamp:
- Apr 8, 2010, 7:46:41 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/save.php
r420 r427 7 7 // Ochrana proti neoprávněnému přístupu 8 8 // if($User->Licence(LICENCE_USER) == false) die('Nemáte přístup do této sekce! Je nutné se přihásit.'); 9 10 $CompleteText = array('nedokončený', 'dokončený'); 9 11 10 12 $GroupId = LoadGroupIdParameter(); … … 36 38 $Filter = ''; 37 39 foreach($Group['Items'] as $GroupItem) 38 if($GroupItem['Visible'] == 1) 39 $Filter .= ' AND (`'.$GroupItem['Column'].'` = "'.$EnglishText[$GroupItem['Column']].'")'; 40 if(($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != '')) 41 $Filter .= ' OR (`'.$GroupItem['Column'].'` = "'.$EnglishText[$GroupItem['Column']].'")'; 42 $Filter = ' AND ('.substr($Filter, 3).')'; 40 43 41 44 $DbResult = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Language` = 0)'.$Filter); 42 while($ DbRow= $DbResult->fetch_assoc())45 while($EnglishFound = $DbResult->fetch_assoc()) 43 46 { 44 47 // Get user translation paired to found english item entry 45 $DbResult2 = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$User->Id.') AND (`Entry` = '.$ DbRow['Entry'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') AND (`VersionEnd` = '.$SourceText['VersionEnd'].')');48 $DbResult2 = $System->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$User->Id.') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart'].') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')'); 46 49 if($DbResult2->num_rows > 0) 47 50 { 48 51 $ExistedText = $DbResult2->fetch_assoc(); 49 $Values = '`Language` = '.$Language.', `Complete`='.$Complete; 52 $Values = '`Language` = '.$Language.', `ModifyTime` = NOW()'; 53 54 $Completable = true; 55 $CompleteParts = $ExistedText['CompleteParts']; 50 56 foreach($Group['Items'] as $GroupItem) 51 57 { 52 58 if($GroupItem['Visible'] == 1) 53 if(array_key_exists($GroupItem['Column'], $_POST)) 54 $Values .= ', `'.$GroupItem['Column'].'` = "'.$_POST[$GroupItem['Column']].'"'; 55 } 59 { 60 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 61 if(array_key_exists($GroupItem['Column'], $_POST)) 62 { 63 $Values .= ', `'.$GroupItem['Column'].'` = "'.$_POST[$GroupItem['Column']].'"'; 64 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 65 } 66 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 67 } 68 } 69 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 70 else $NewComplete = 0; 71 if($SourceText['ID'] == $ExistedText['ID']) 72 { 73 $NewComplete = $Complete; // Our original user text, set complete according user choice 74 if($Complete == 1) 75 { 76 foreach($Group['Items'] as $GroupItem) 77 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 78 } 79 } 80 $Values .= ', `Complete`='.$NewComplete.', `CompleteParts` = '.$CompleteParts; 56 81 57 82 // Update user translation 58 83 $System->Database->query('UPDATE `'.$Table.'` SET '.$Values.' WHERE `ID` = '.$ExistedText['ID']); 59 84 60 echo('Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$ExistedText['ID'].'">'.$ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy !<br />');61 WriteLog('Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$ExistedText['ID'].'">'.$ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy .', LOG_TYPE_TRANSLATION);85 echo('Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$ExistedText['ID'].'">'.$ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.<br />'); 86 WriteLog('Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$ExistedText['ID'].'">'.$ExistedText['ID'].'</a> ('.$ExistedText['Entry'].') uloženy jako '.$CompleteText[$NewComplete].'.', LOG_TYPE_TRANSLATION); 62 87 } else 63 88 { 64 89 // Insert new user translation 65 $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `Complete`, `User`, `Take`'; 66 $Values = $DbRow['Entry'].', '.$DbRow['VersionStart'].', '.$DbRow['VersionEnd'].', '.$Language.', '.$Complete.', '.$User->Id.', '.$SourceText['ID']; 90 $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `User`, `Take`, `ModifyTime`'; 91 $Values = $EnglishFound['Entry'].', '.$EnglishFound['VersionStart'].', '.$EnglishFound['VersionEnd'].', '.$Language.', '.$User->Id.', '.$SourceText['ID'].', NOW()'; 92 93 $CompleteParts = 0; 94 $Completable = true; 67 95 foreach($Group['Items'] as $GroupItem) 68 96 { 97 $Columns .= ', `'.$GroupItem['Column'].'`'; 69 98 if($GroupItem['Visible'] == 1) 70 99 { 71 // Read form user data 72 if(array_key_exists($GroupItem['Column'], $_POST)) 100 if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']]) 73 101 { 74 $Columns .= ', `'.$GroupItem['Column'].'`'; 75 $Values .= ', "'.$_POST[$GroupItem['Column']].'"'; 76 } 102 // Read form user data 103 if(array_key_exists($GroupItem['Column'], $_POST)) 104 { 105 $Values .= ', "'.$_POST[$GroupItem['Column']].'"'; 106 $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 107 } else $Values .= ', "'.$EnglishFound[$GroupItem['Column']].'"'; 108 } else $Values .= ', "'.$EnglishFound[$GroupItem['Column']].'"'; 109 if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false; 77 110 } else 78 111 { 79 112 // Read from english text 80 $Columns .= ', `'.$GroupItem['Column'].'`'; 81 $Values .= ', "'.$DbRow[$GroupItem['Column']].'"'; 82 } 83 } 113 $Values .= ', "'.$EnglishFound[$GroupItem['Column']].'"'; 114 } 115 } 116 if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed 117 else $NewComplete = 0; 118 if($SourceText['ID'] == $EnglishFound['ID']) 119 { 120 $NewComplete = $Complete; // Our original user text, set complete according user choice 121 if($Complete == 1) 122 { 123 foreach($Group['Items'] as $GroupItem) 124 if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1)); 125 } 126 } 127 $Columns .= ', `Complete`, `CompleteParts`'; 128 $Values .= ', '.$NewComplete.', '.$CompleteParts; 129 130 //echo('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')'); 84 131 $System->Database->query('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')'); 85 132 $LastID = $System->Database->insert_id; 86 133 87 echo('Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen !Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.<br/>');88 WriteLog('Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen !Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.', LOG_TYPE_TRANSLATION);134 echo('Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.<br/>'); 135 WriteLog('Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.$GroupId.'&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.', LOG_TYPE_TRANSLATION); 89 136 } 90 137 }
Note:
See TracChangeset
for help on using the changeset viewer.