Legend:
- Unmodified
- Added
- Removed
-
base.php
r29 r30 1 1 <?php 2 3 function GetListTableName($List) 4 { 5 if($List['Database'] != '') return('`'.$List['Database'].'`.`'.$List['TableName'].'`'); 6 else return('`'.$List['TableName'].'`'); 7 } 2 8 3 9 function ShowList($List, $Column = '', $ColumnValue = 0, $Title = '', $Filter = '') … … 54 60 //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))'; 55 61 $Where .= ' '.$Order; 56 $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM `'.$List['TableName'].'`WHERE '.$Where);62 $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM '.GetListTableName($List).' WHERE '.$Where); 57 63 $DbRow = $DbResult->fetch_row(); 58 64 $TotalItemCount = $DbRow[0]; 59 65 60 $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'`WHERE '.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);66 $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']); 61 67 //echo($Database->LastQuery); 62 68 while($DbRow = $DbResult->fetch_assoc()) … … 67 73 if($Item['VisibleInList'] == 1) 68 74 { 69 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[ 'Id'], 'Type' => $Item['Type']);75 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); 70 76 $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>'; 71 77 } 72 78 } 73 79 $Output .= '<td>'; 74 if(CheckPermission('Read', $List['Id'])) $Output .= '<a href="?Action=ViewItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>';75 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>';76 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat" onclick="return confirmAction(\'Opravdu smazat položku?\');"></a>';80 if(CheckPermission('Read', $List['Id'])) $Output .= '<a href="?Action=ViewItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>'; 81 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>'; 82 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat" onclick="return confirmAction(\'Opravdu smazat položku?\');"></a>'; 77 83 $Output .= '</td></tr>'; 78 84 } … … 158 164 159 165 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 160 $DbResult = $Database-> select($List['TableName'], '*', 'Id='.$Id);166 $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); 161 167 while($DbRow = $DbResult->fetch_assoc()) 162 168 { … … 169 175 if($Item['Editable'] == 1) 170 176 { 171 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[ 'Id'], 'Type' => $Item['Type']);177 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); 172 178 } else $DefinitionItems[] = array('Name' => $Index, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $DbRow[$Index]); 173 179 } … … 198 204 199 205 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 200 $DbResult = $Database-> select($List['TableName'], '*', 'Id='.$Id);206 $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); 201 207 while($DbRow = $DbResult->fetch_assoc()) 202 208 { … … 207 213 if($Type['BaseType'] != 'PointerOneToMany') 208 214 { 209 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[ 'Id'], 'Type' => $Item['Type']);215 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); 210 216 } 211 217 } … … 227 233 $Form->Values['Id'] = $Id; 228 234 $Form->Values['ListTableName'] = $List['TableName']; 235 $Form->Values['ListDatabaseName'] = $List['Database']; 229 236 ExecuteListEvent($List['Id'], 'OnEdit', $Form->Values); 230 237 return($Output); … … 320 327 if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 321 328 $Output = ''; 322 $DbResult = $Database-> select($List['TableName'], '*', 'Id='.$Id);329 $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); 323 330 while($DbRow = $DbResult->fetch_assoc()) 324 331 { … … 340 347 ); 341 348 $Output .= $Form->ShowReadOnlyForm(); 342 if(CheckPermission('Write', $List['Id'])) $Output .= '<a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'">Editovat</a> ';349 if(CheckPermission('Write', $List['Id'])) $Output .= '<a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'">Editovat</a> '; 343 350 344 351 if(($Column != '') and ($ColumnValue != 0)) … … 349 356 $Output .= '<a href="?Action=ShowList&Table='.$List['Id'].'">Celkový seznam</a>'; 350 357 } 351 $Output .= ' <a href="?Action=ShowHistory&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'">Historie</a>';352 $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';358 $Output .= ' <a href="?Action=ShowHistory&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'">Historie</a>'; 359 $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>'; 353 360 $Output .= '<div class="line"></div>'; 354 361 foreach($List['Items'] as $Index => $Item) … … 358 365 { 359 366 $SubList = GetListDefinition($Type['Parameters'][0]); 360 $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow[ 'Id'], $Item['TextBefore']).'<br /><br />';367 $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow[$List['IdName']], $Item['TextBefore']).'<br /><br />'; 361 368 } 362 369 } … … 472 479 while($DbRow2 = $DbResult2->fetch_assoc()) 473 480 { 474 if(CheckPermission('Read', $DbRow2[ 'Id']))481 if(CheckPermission('Read', $DbRow2[$List['IdName']])) 475 482 $Group .= '<a href="?Action=ShowList&Table='.$DbRow2['Id'].'">'.$DbRow2['Title'].'</a><br />'; 476 483 } … … 485 492 function Output() 486 493 { 494 //print_r($_SESSION); 487 495 $PermanentVar = array('Table', 'Item', 'Column', 'ColumnValue', 'Action'); 488 496 if($_GET['Table'] != $_SESSION['Table']) … … 496 504 } 497 505 $Output = ''; 498 if(array_key_exists('Table', $_SESSION) )506 if(array_key_exists('Table', $_SESSION) and ($_SESSION['Table'] != '')) 499 507 { 500 508 $List = GetListDefinition($_SESSION['Table']); … … 561 569 'Id' => $DbRow['Id'], 562 570 'TableName' => $DbRow['TableName'], 571 'Database' => $DbRow['Database'], 563 572 'Title' => $DbRow['Title'], 573 'IdName' => $DbRow['IdName'], 564 574 'Items' => $Items, 565 575 ); … … 643 653 global $Database; 644 654 645 $DbResult = $Database->select( 'SystemList', '*');655 $DbResult = $Database->select(array('Table' => 'SystemList')); 646 656 while($DbRow = $DbResult->fetch_assoc()) 647 657 {
Note:
See TracChangeset
for help on using the changeset viewer.