Changeset 28
- Timestamp:
- Dec 8, 2008, 11:06:23 AM (16 years ago)
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
base.php
r27 r28 5 5 global $Database, $Config; 6 6 7 if(!CheckPermission('Read', $List['I temId']))7 if(!CheckPermission('Read', $List['Id'])) 8 8 { 9 9 if($Column != '') return(''); … … 21 21 $Output .= '<th>Akce</th></tr>'; 22 22 23 $Where = ' AND (t1.DeletionTime IS NULL)';23 $Where = '1'; 24 24 25 25 if(($Column != '') and ($ColumnValue != 0)) 26 26 { 27 $Where .= ' AND ( t1.'.$Column.'='.$ColumnValue.')';27 $Where .= ' AND ('.$Column.'='.$ColumnValue.')'; 28 28 $ColumnSelection = '&Column='.$Column.'&ColumnValue='.$ColumnValue; 29 $FullListLink = '<a href="?Action=ViewList&Table='.$List['I temId'].'">Celkový seznam</a>';29 $FullListLink = '<a href="?Action=ViewList&Table='.$List['Id'].'">Celkový seznam</a>'; 30 30 } else 31 31 { … … 39 39 if($_SESSION['OrderColumn'] == $_GET['OrderColumn']) // Same column => reverse order 40 40 $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2; 41 if($_SESSION['OrderTable'] != $List['I temId']) // Different table => set ascending order41 if($_SESSION['OrderTable'] != $List['Id']) // Different table => set ascending order 42 42 $_SESSION['OrderDirection'] = 0; 43 43 $_SESSION['OrderColumn'] = $_GET['OrderColumn']; 44 $_SESSION['OrderTable'] = $List['I temId'];45 } 46 if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['I temId']))44 $_SESSION['OrderTable'] = $List['Id']; 45 } 46 if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['Id'])) 47 47 { 48 48 $OrderDirection = array('ASC', 'DESC'); 49 $Order = 'ORDER BY t1.`'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']];49 $Order = 'ORDER BY `'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']]; 50 50 } else $Order = ''; 51 51 … … 53 53 //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))'; 54 54 $Where .= ' '.$Order; 55 $DbResult = $Database->query('SELECT COUNT( t2.Id) AS Count FROM (SELECT DISTINCT(ItemId) as Id FROM `'.$List['TableName'].'` as t1 WHERE 1'.$Where.') as t2');55 $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM `'.$List['TableName'].'` WHERE 1'.$Where); 56 56 $DbRow = $DbResult->fetch_row(); 57 57 $TotalItemCount = $DbRow[0]; 58 58 59 $DbResult = $Database->query('SELECT t1.* FROM `'.$List['TableName'].'` AS t1 LEFT JOIN `'.$List['TableName'].'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);59 $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'` WHERE '.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']); 60 60 //echo($Database->LastQuery); 61 61 while($DbRow = $DbResult->fetch_assoc()) … … 66 66 if($Item['VisibleInList'] == 1) 67 67 { 68 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['I temId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);68 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 69 69 $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>'; 70 70 } 71 71 } 72 72 $Output .= '<td>'; 73 if(CheckPermission('Read', $List['I temId'])) $Output .= '<a href="?Action=ViewItem&Table='.$List['ItemId'].'&Item='.$DbRow['ItemId'].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>';74 if(CheckPermission('Write', $List['I temId'])) $Output .= ' <a href="?Action=EditItem&Table='.$List['ItemId'].'&Item='.$DbRow['ItemId'].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>';75 if(CheckPermission('Write', $List['I temId'])) $Output .= ' <a href="?Action=DeleteItem&Table='.$List['ItemId'].'&Item='.$DbRow['ItemId'].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat" onclick="return confirmAction(\'Opravdu smazat položku?\');"></a>';73 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>'; 74 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>'; 75 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>'; 76 76 $Output .= '</td></tr>'; 77 77 } … … 79 79 $PageList = PagesList($Page, $TotalItemCount); 80 80 if(strlen($PageList) != 0) $Output .= $PageList.'<br />'; 81 if(CheckPermission('Write', $List['ItemId'])) $Output .= ' <a href="?Action=AddItem&Table='.$List['ItemId'].$ColumnSelection.'">Přidat</a> '.$FullListLink; 82 if(CheckPermission('Read', $List['ItemId'])) $Output .= ' <a href="?Action=ShowSearch&Table='.$List['ItemId'].$ColumnSelection.'">Hledat</a> '.$FullListLink; 83 return($Output); 84 } 85 81 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=AddItem&Table='.$List['Id'].$ColumnSelection.'">Přidat</a> '.$FullListLink; 82 if(CheckPermission('Read', $List['Id'])) $Output .= ' <a href="?Action=ShowSearch&Table='.$List['Id'].$ColumnSelection.'">Hledat</a> '.$FullListLink; 83 return($Output); 84 } 85 86 /* 86 87 function ShowHistory($List, $Id, $Title = '') 87 88 { … … 149 150 return($Output); 150 151 } 152 */ 151 153 152 154 function ShowEditItem($List, $Id) … … 154 156 global $Database; 155 157 156 if(!CheckPermission('Write', $List['I temId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));157 $DbResult = $Database->select($List['TableName'], '*', 'I temId='.$Id.' ORDER BY Id DESC LIMIT 1');158 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 159 $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id); 158 160 while($DbRow = $DbResult->fetch_assoc()) 159 161 { … … 166 168 if($Item['Editable'] == 1) 167 169 { 168 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['I temId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);170 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 169 171 } else $DefinitionItems[] = array('Name' => $Index, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $DbRow[$Index]); 170 172 } … … 182 184 if(($Column != '') and ($ColumnValue != 0)) 183 185 { 184 $Output .= '<a href="?Action=ShowList&Table='.$List['I temId'].'&Column='.$Column.'&ColumnValue='.$ColumnValue.'">Celkový seznam</a>';186 $Output .= '<a href="?Action=ShowList&Table='.$List['Id'].'&Column='.$Column.'&ColumnValue='.$ColumnValue.'">Celkový seznam</a>'; 185 187 } else 186 188 { 187 $Output .= '<a href="?Action=ShowList&Table='.$List['I temId'].'">Celkový seznam</a>';189 $Output .= '<a href="?Action=ShowList&Table='.$List['Id'].'">Celkový seznam</a>'; 188 190 } 189 191 return($Output); … … 194 196 global $Database, $System, $LogActionType; 195 197 196 if(!CheckPermission('Write', $List['I temId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));197 $DbResult = $Database->select($List['TableName'], '*', 'I temId='.$Id.' ORDER BY Id DESC LIMIT 1');198 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 199 $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id); 198 200 while($DbRow = $DbResult->fetch_assoc()) 199 201 { … … 204 206 if($Type['BaseType'] != 'PointerOneToMany') 205 207 { 206 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['I temId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);208 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); 207 209 } 208 210 } … … 216 218 ); 217 219 $Form->LoadValuesFromForm(); 218 $System->Modules['DatabaseList']->EditItem($List['I temId'], $Form->Values, $Id);220 $System->Modules['DatabaseList']->EditItem($List['Id'], $Form->Values, $Id); 219 221 $NewId = $Database->insert_id; 220 $System->Modules['Log']->Add($List['I temId'], $NewId, $LogActionType['Edit']);222 $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Edit']); 221 223 $Output = 'Změny uloženy.'; 222 224 $Output .= ShowViewItem($List, $Id); 223 225 $Form->Values['Column'] = $_POST['Column']; 224 $Form->Values['I temId'] = $Id;226 $Form->Values['Id'] = $Id; 225 227 $Form->Values['ListTableName'] = $List['TableName']; 226 ExecuteListEvent($List['I temId'], 'OnEdit', $Form->Values);228 ExecuteListEvent($List['Id'], 'OnEdit', $Form->Values); 227 229 return($Output); 228 230 } … … 232 234 global $Database; 233 235 234 if(!CheckPermission('Write', $List['I temId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));236 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 235 237 $DefinitionItems = array(); 236 238 $AfterTableOutput = ''; … … 243 245 if($Item['Required'] == 1) $Required = '*'; else $Required = ''; 244 246 if($Item['Editable'] == 1) 245 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['I temId'], 'SourceItemId' => 0);247 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['Id'], 'SourceItemId' => 0); 246 248 } else 247 249 if($Item['Name'] == $Column) … … 263 265 if(($Column != '') and ($ColumnValue != 0)) 264 266 { 265 $Output .= '<a href="?Action=ShowList&Table='.$List['I temId'].'&Column='.$Column.'&ColumnValue='.$ColumnValue.'">Celkový seznam</a>';267 $Output .= '<a href="?Action=ShowList&Table='.$List['Id'].'&Column='.$Column.'&ColumnValue='.$ColumnValue.'">Celkový seznam</a>'; 266 268 } else 267 269 { 268 $Output .= '<a href="?Action=ShowList&Table='.$List['I temId'].'">Celkový seznam</a>';270 $Output .= '<a href="?Action=ShowList&Table='.$List['Id'].'">Celkový seznam</a>'; 269 271 } 270 272 return($Output); … … 275 277 global $Database, $System, $LogActionType; 276 278 277 if(!CheckPermission('Write', $List['I temId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));279 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 278 280 $DefinitionItems = array(); 279 281 $AfterTableOutput = ''; … … 285 287 { 286 288 if($Item['Required'] == 1) $Required = '*'; else $Required = ''; 287 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['I temId'], 'SourceItemId' => 0);289 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['Id'], 'SourceItemId' => 0); 288 290 } else 289 291 if($Item['Name'] == $Column) … … 301 303 ); 302 304 $Form->LoadValuesFromForm(); 303 $NewItemId = $System->Modules['DatabaseList']->AddItem($List['I temId'], $Form->Values);305 $NewItemId = $System->Modules['DatabaseList']->AddItem($List['Id'], $Form->Values); 304 306 $NewId = $Database->insert_id; 305 $System->Modules['Log']->Add($List['I temId'], $NewId, $LogActionType['Add']);307 $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']); 306 308 $Output = 'Položka přidána'; 307 309 $Output .= ShowViewItem($List, $NewItemId); 308 310 $Form->Values['Column'] = $_POST['Column']; 309 ExecuteListEvent($List['I temId'], 'OnAdd', $Form->Values);311 ExecuteListEvent($List['Id'], 'OnAdd', $Form->Values); 310 312 return($Output); 311 313 } … … 315 317 global $Database; 316 318 317 if(!CheckPermission('Read', $List['I temId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));319 if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 318 320 $Output = ''; 319 $DbResult = $Database->select($List['TableName'], '*', 'I temId='.$Id.' ORDER BY Id DESC LIMIT 1');321 $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id); 320 322 while($DbRow = $DbResult->fetch_assoc()) 321 323 { … … 327 329 if($Type['BaseType'] != 'PointerOneToMany') 328 330 { 329 $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['I temId'], 'SourceItemId' => 0);331 $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0); 330 332 } 331 333 } … … 337 339 ); 338 340 $Output .= $Form->ShowReadOnlyForm(); 339 if(CheckPermission('Write', $List['I temId'])) $Output .= '<a href="?Action=EditItem&Table='.$List['ItemId'].'&Item='.$DbRow['ItemId'].'">Editovat</a> ';341 if(CheckPermission('Write', $List['Id'])) $Output .= '<a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow['Id'].'">Editovat</a> '; 340 342 341 343 if(($Column != '') and ($ColumnValue != 0)) 342 344 { 343 $Output .= '<a href="?Action=ShowList&Table='.$List['I temId'].'&Column='.$Column.'&ColumnValue='.$ColumnValue.'">Celkový seznam</a>';345 $Output .= '<a href="?Action=ShowList&Table='.$List['Id'].'&Column='.$Column.'&ColumnValue='.$ColumnValue.'">Celkový seznam</a>'; 344 346 } else 345 347 { 346 $Output .= '<a href="?Action=ShowList&Table='.$List['I temId'].'">Celkový seznam</a>';347 } 348 $Output .= ' <a href="?Action=ShowHistory&Table='.$List['I temId'].'&Item='.$DbRow['ItemId'].'">Historie</a>';349 $Output .= ' <a href="?Action=DeleteItem&Table='.$List['I temId'].'&Item='.$DbRow['ItemId'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';348 $Output .= '<a href="?Action=ShowList&Table='.$List['Id'].'">Celkový seznam</a>'; 349 } 350 $Output .= ' <a href="?Action=ShowHistory&Table='.$List['Id'].'&Item='.$DbRow['Id'].'">Historie</a>'; 351 $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>'; 350 352 $Output .= '<div class="line"></div>'; 351 353 foreach($List['Items'] as $Index => $Item) … … 355 357 { 356 358 $SubList = GetListDefinition($Type['Parameters'][0]); 357 $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow['I temId'], $Item['TextBefore']).'<br /><br />';359 $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow['Id'], $Item['TextBefore']).'<br /><br />'; 358 360 } 359 361 } … … 366 368 global $Database, $System, $LogActionType; 367 369 368 if(!CheckPermission('Write', $List['I temId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));369 $System->Modules['Log']->Add($List['I temId'], $Id, $LogActionType['Delete']);370 $System->Modules['DatabaseList']->DeleteItem($List['I temId'], $Id);370 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 371 $System->Modules['Log']->Add($List['Id'], $Id, $LogActionType['Delete']); 372 $System->Modules['DatabaseList']->DeleteItem($List['Id'], $Id); 371 373 $Output = 'Položka smazána.'; 372 374 $Output .= ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']).'<br /><br />'; 373 ExecuteListEvent($List['I temId'], 'OnDelete', $Id);375 ExecuteListEvent($List['Id'], 'OnDelete', $Id); 374 376 return($Output); 375 377 } … … 379 381 global $Database; 380 382 381 if(!CheckPermission('Read', $List['I temId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));383 if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 382 384 $DefinitionItems = array(); 383 385 $AfterTableOutput = ''; … … 389 391 { 390 392 if($Item['Editable'] == 1) 391 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => '', 'SourceTable' => $List['I temId'], 'SourceItemId' => 0);393 $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => '', 'SourceTable' => $List['Id'], 'SourceItemId' => 0); 392 394 } else 393 395 if($Item['Name'] == $Column) … … 414 416 global $Database, $System, $LogActionType; 415 417 416 if(!CheckPermission('Write', $List['I temId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));417 $System->Modules['Log']->Add($List['I temId'], $Id, $LogActionType['Delete']);418 $System->Modules['DatabaseList']->DeleteItem($List['I temId'], $Id);418 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 419 $System->Modules['Log']->Add($List['Id'], $Id, $LogActionType['Delete']); 420 $System->Modules['DatabaseList']->DeleteItem($List['Id'], $Id); 419 421 $Output = 'Položka smazána.'; 420 422 $Output .= ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']).'<br /><br />'; 421 ExecuteListEvent($List['I temId'], 'OnDelete', $Id);423 ExecuteListEvent($List['Id'], 'OnDelete', $Id); 422 424 return($Output); 423 425 … … 431 433 432 434 $Output = ''; 433 $DbResult = $Database->query('SELECT t1.* FROM `SystemMenu` AS t1 LEFT JOIN `SystemMenu` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL)');435 $DbResult = $Database->query('SELECT * FROM `SystemMenu`'); 434 436 while($DbRow = $DbResult->fetch_assoc()) 435 437 { 436 438 $Group = ''; 437 $DbResult2 = $Database->query('SELECT t1.* FROM `SystemList` AS t1 LEFT JOIN `SystemList` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND (t1.`Menu` = '.$DbRow['ItemId'].')');439 $DbResult2 = $Database->query('SELECT * FROM `SystemList` WHERE `Menu` = '.$DbRow['Id']); 438 440 while($DbRow2 = $DbResult2->fetch_assoc()) 439 441 { 440 if(CheckPermission('Read', $DbRow2['I temId']))441 $Group .= '<a href="?Action=ShowList&Table='.$DbRow2['I temId'].'">'.$DbRow2['Title'].'</a><br />';442 if(CheckPermission('Read', $DbRow2['Id'])) 443 $Group .= '<a href="?Action=ShowList&Table='.$DbRow2['Id'].'">'.$DbRow2['Title'].'</a><br />'; 442 444 } 443 445 if($Group != '') … … 511 513 if(!array_key_exists($Id, $Lists)) 512 514 { 513 $DbResult = $Database->query('SELECT t1.* FROM `SystemList` AS t1 LEFT JOIN `SystemList` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND t1.ItemId="'.$Id.'"');515 $DbResult = $Database->query('SELECT * FROM `SystemList` WHERE Id='.$Id); 514 516 if($DbResult->num_rows > 0) 515 517 { 516 518 $DbRow = $DbResult->fetch_assoc(); 517 519 $Items = array(); 518 $DbResult2 = $Database->query('SELECT t1.* FROM `SystemListItem` AS t1 LEFT JOIN `SystemListItem` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND (t1.List='.$DbRow['ItemId'].')');520 $DbResult2 = $Database->query('SELECT * FROM `SystemListItem` WHERE List='.$DbRow['Id']); 519 521 while($DbRow2 = $DbResult2->fetch_assoc()) 520 522 { … … 523 525 $List = array( 524 526 'Id' => $DbRow['Id'], 525 'ItemId' => $DbRow['ItemId'],526 527 'TableName' => $DbRow['TableName'], 527 528 'Title' => $DbRow['Title'], … … 533 534 if(class_exists($ClassName)) $List['Class'] = new $ClassName; 534 535 } 535 $Lists[$List['I temId']] = $List;536 } else $Lists[$List['I temId']] = NULL;536 $Lists[$List['Id']] = $List; 537 } else $Lists[$List['Id']] = NULL; 537 538 } 538 539 return($Lists[$Id]); … … 546 547 if(!array_key_exists($Id, $Types)) 547 548 { 548 $DbResult = $Database->query('SELECT t1.* FROM `SystemType` AS t1 LEFT JOIN `SystemType` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND t1.ItemId='.$Id);549 $DbResult = $Database->query('SELECT * FROM `SystemType` WHERE Id='.$Id); 549 550 if($DbResult->num_rows > 0) 550 551 { … … 553 554 if(($DbRow['ParentType'] == TypePointerOneToOneId) or ($DbRow['ParentType'] == TypePointerOneToManyId)) 554 555 { 555 $DbResult2 = $Database->query('SELECT t1.* FROM `SystemList` AS t1 LEFT JOIN `SystemType` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND t1.TableName="'.$DbRow['Parameters'][0].'"');556 $DbResult2 = $Database->query('SELECT * FROM `SystemList` WHERE TableName="'.$DbRow['Parameters'][0].'"'); 556 557 $DbRow2 = $DbResult2->fetch_assoc(); 557 558 //echo($DbRow['ParentType'].'-'.$DbRow['Parameters'][0].'='.$DbRow2['ItemId'].'<br>'); 558 $DbRow['Parameters'][0] = $DbRow2['I temId'];559 $DbRow['Parameters'][0] = $DbRow2['Id']; 559 560 } 560 561 $DbRow['BaseType'] = $DbRow['Name']; … … 577 578 } 578 579 $DbRow['Class'] = &$TypeDefinitionList[$DbRow['BaseType']]; 579 $Types[$DbRow['I temId']] = $DbRow;580 } else $Types[$DbRow['I temId']] = NULL;580 $Types[$DbRow['Id']] = $DbRow; 581 } else $Types[$DbRow['Id']] = NULL; 581 582 } 582 583 //print_r($Types); … … 620 621 $Result = FALSE; 621 622 //return(TRUE); 622 $DbResult = $Database->query('SELECT t1.* FROM `Permission` AS t1 LEFT JOIN `Permission` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND t1.PermissionGroup = (SELECT PermissionGroup.Id FROM PermissionGroup WHERE PermissionGroup.Id=(SELECT User.PermissionGroup FROM User WHERE User.ItemId='.$System->Modules['User']->User['ItemId'].' ORDER BY User.Id DESC LIMIT 1) ORDER BY PermissionGroup.Id DESC LIMIT 1) AND t1.DeletionTime IS NULLAND t1.List='.$ListId);623 $DbResult = $Database->query('SELECT t1.* FROM `Permission` AS t1 WHERE t1.PermissionGroup = (SELECT PermissionGroup.Id FROM PermissionGroup WHERE PermissionGroup.Id=(SELECT User.PermissionGroup FROM User WHERE User.Id='.$System->Modules['User']->User['Id'].')) AND t1.List='.$ListId); 623 624 if($DbResult->num_rows > 0) 624 625 { -
database_list.php
r24 r28 7 7 function AddItem($TableId, $Values) 8 8 { 9 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE I temId='.$TableId.' ORDER BY Id DESC LIMIT 1');9 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId); 10 10 $DbRow = $DbResult->fetch_assoc(); 11 11 $TableName = $DbRow['TableName']; 12 12 13 $Values['Author'] = $this->System->Modules['User']->User['ItemId'];14 $Values['CreationTime'] = 'NOW()';15 $Values['ValidTimeFrom'] = 'NOW()';16 $DbResult = $this->Database->select($TableName, 'MAX(ItemId)');17 $DbRow = $DbResult->fetch_row();18 $AutoincrementId = $DbRow[0];19 $Values['ItemId'] = $AutoincrementId + 1;20 13 $this->Database->insert($TableName, $Values); 21 return($ Values['ItemId']);14 return($this->Database->insert_id); 22 15 } 23 16 24 17 function DeleteItem($TableId, $ItemId) 25 18 { 26 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE I temId='.$TableId.' ORDER BY Id DESC LIMIT 1');19 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId); 27 20 $DbRow = $DbResult->fetch_assoc(); 28 21 $TableName = $DbRow['TableName']; 29 30 $DbResult = $this->Database->select($TableName, 'Id', 'ItemId='.$ItemId.' ORDER BY Id DESC LIMIT 1'); 31 $DbRow = $DbResult->fetch_assoc(); 32 $this->Database->update($TableName, 'Id='.$DbRow['Id'], array('DeletionTime' => 'NOW()')); 22 $this->Database->delete($TableName, 'Id='.$ItemId, array('DeletionTime' => 'NOW()')); 33 23 } 34 24 35 25 function EditItem($TableId, $Values, $ItemId) 36 26 { 37 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE I temId='.$TableId.' ORDER BY Id DESC LIMIT 1');27 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId); 38 28 $DbRow = $DbResult->fetch_assoc(); 39 29 $TableName = $DbRow['TableName']; 40 30 $this->DeleteItem($TableId, $ItemId); 41 $Values['ItemId'] = $ItemId; 42 $Values['Author'] = $this->System->Modules['User']->User['ItemId']; 43 $Values['CreationTime'] = 'NOW()'; 44 $Values['ValidTimeFrom'] = 'NOW()'; 45 $this->Database->insert($TableName, $Values); 31 $Values['Id'] = $ItemId; 32 $this->Database->replace($TableName, $Values); 46 33 } 47 34 } -
lists/SystemList.php
r26 r28 9 9 $Database->query('CREATE TABLE IF NOT EXISTS `'.$Parameters['TableName'].'` ( 10 10 `Id` int(11) NOT NULL auto_increment, 11 `ItemId` int(11) NOT NULL,12 `Author` int(11) NOT NULL,13 `ValidTimeFrom` datetime default NULL,14 `ValidTimeTo` datetime default NULL,15 `CreationTime` datetime default NULL,16 `DeletionTime` datetime default NULL,17 11 PRIMARY KEY (`Id`) 18 12 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 19 $Database->query('ALTER TABLE `'.$Parameters['TableName'].'` ADD INDEX ( `ItemId` );');20 13 //echo($Database->LastQuery); 21 14 } … … 25 18 global $Database; 26 19 27 $DbResult = $Database->query('SELECT `TableName` FROM `'.$Parameters['ListTableName'].'` WHERE I temId='.$Parameters['ItemId'].' ORDER BY `Id` DESC LIMIT 1,1');20 $DbResult = $Database->query('SELECT `TableName` FROM `'.$Parameters['ListTableName'].'` WHERE Id='.$Parameters['Id']); 28 21 $DbRow = $DbResult->fetch_assoc(); 29 22 if($DbRow['TableName'] != $Parameters['TableName']) 30 23 $Database->query('RENAME TABLE `'.$DbRow['TableName'].'` TO `'.$Parameters['TableName'].'`'); 31 24 } 25 26 function ApplySQLToItems($SQL) 27 { 28 global $Database; 29 30 $DbResult = $Database->query('SELECT `TableName` FROM `SystemList`'); 31 while($DbRow = $DbResult->fetch_assoc()) 32 { 33 $Database->query(str_replace('`TableName`', '`'.$DbRow['TableName'].'`', $SQL)); 34 } 35 } 32 36 } 33 37 -
lists/SystemListItem.php
r27 r28 7 7 global $Database; 8 8 9 $Database->query('UPDATE SystemListItem AS Table1 SET Sequence = (SELECT COUNT(*) FROM (SELECT * FROM SystemListItem) AS Table2 WHERE ( Table1.ItemId = Table2.ItemId) AND ((Table2.Sequence < Table1.Sequence) OR ((Table1.Sequence = Table2.Sequence) AND (Table2.Id < Table1.Id))))');9 $Database->query('UPDATE SystemListItem AS Table1 SET Sequence = (SELECT COUNT(*) FROM (SELECT * FROM SystemListItem) AS Table2 WHERE ((Table2.Sequence < Table1.Sequence) OR ((Table1.Sequence = Table2.Sequence) AND (Table2.Id < Table1.Id))))'); 10 10 } 11 11 … … 15 15 16 16 //print_r($Parameters); 17 $DbResult = $Database->query('SELECT DbDataType FROM SystemType WHERE I temId='.$Parameters['Type'].' ORDER BY Id DESC LIMIT 1');17 $DbResult = $Database->query('SELECT DbDataType FROM SystemType WHERE Id='.$Parameters['Type']); 18 18 //echo($Database->LastQuery); 19 19 $DbRow = $DbResult->fetch_assoc(); 20 $DbResult = $Database->query('SELECT TableName FROM SystemList WHERE I temId='.$Parameters[$Parameters['Column']].' ORDER BY Id DESC LIMIT 1');20 $DbResult = $Database->query('SELECT TableName FROM SystemList WHERE Id='.$Parameters[$Parameters['Column']]); 21 21 //echo($Database->LastQuery); 22 22 $DbRow2 = $DbResult->fetch_assoc(); -
lists/include.php
r24 r28 5 5 include('lists/SystemListItem.php'); 6 6 7 define('ListSystemLogId', 20);7 define('ListSystemLogId', 59); 8 8 9 9 ?> -
types/PointerOneToOne.php
r26 r28 11 11 $List = GetListDefinition($Type['Parameters'][0]); 12 12 $TargetTable = $List['TableName']; 13 //echo($TargetTable.'<'); 14 //print_r($List); 13 15 foreach($List['Items'] as $Index => $ListItem) 14 16 { … … 21 23 { 22 24 //print_r($Type); 23 $DbResult = $Database->select($List['TableName'], '*', 'I temId='.$Item['Value'].' ORDER BY Id DESC LIMIT 1');25 $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Item['Value']); 24 26 $DbRow = $DbResult->fetch_assoc(); 25 $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['I temId'], 'SourceItemId' => 0);27 $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0); 26 28 $SubTarget = $this->GetTablePointerName($Type, $DefinitionItem); 27 29 $Columns .= '"'.$SubTarget['Name'].' ",'; … … 29 31 } 30 32 } 31 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, ItemId, Id'; 32 $DbResult = $Database->select($TargetTable, $Columns, 'ItemId='.$Item['Value'].' AND (DeletionTime IS NULL) ORDER BY Id DESC LIMIT 1'); 33 echo($Database->LastQuery); 33 $Columns = substr($Columns, 0, -1); 34 if($Columns == '') $Columns = 'Id AS Name, Id'; 35 else $Columns = 'CONCAT('.$Columns.') AS Name, Id'; 36 $DbResult = $Database->select($TargetTable, $Columns, 'Id='.$Item['Value']); 37 //echo($Database->LastQuery); 34 38 if($DbResult->num_rows > 0) 35 39 { … … 46 50 $TargetTable = $List['TableName']; 47 51 foreach($List['Items'] as $ListItem) 48 if($ListItem['VisibleInPointer'] == 1) $Columns .= ' t1.`'.$ListItem['Name'].'`," ",';49 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, t1.Id, t1.ItemId, t1.DeletionTime';50 $DbResult = $Database->query('SELECT t3.* FROM (SELECT '.$Columns.' FROM `'.$TargetTable.'` AS t1 LEFT JOIN `'.$TargetTable.'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)) AS t3 WHERE t3.DeletionTime IS NULL');52 if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",'; 53 $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id'; 54 $DbResult = $Database->query('SELECT '.$Columns.' FROM `'.$TargetTable.'`'); 51 55 //echo($Database->LastQuery); 52 56 if($DbResult->num_rows > 0) 53 57 { 54 58 55 $Result = array(array('Name' => 'Žádný', 'Id' => 0 , 'ItemId' => 0));59 $Result = array(array('Name' => 'Žádný', 'Id' => 0)); 56 60 while($DbRow = $DbResult->fetch_assoc()) 57 61 $Result[] = $DbRow; … … 67 71 $TargetTable = $Type['Parameters'][0]; 68 72 $TargetName = $this->GetTablePointerName($Type, $Item); 69 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['I temId'].'">'.$TargetName['Name'].'</a>';73 $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>'; 70 74 return($Output); 71 75 } … … 81 85 foreach($TargetNameList as $TargetName) 82 86 { 83 if($Item['Value'] == $TargetName['I temId']) $Selected = ' selected="1"'; else $Selected = '';84 $Output .= '<option value="'.$TargetName['I temId'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';87 if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = ''; 88 $Output .= '<option value="'.$TargetName['Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>'; 85 89 } 86 90 $Output .= '</select>'; -
user.php
r20 r28 54 54 if($Row['User'] != 0) 55 55 { 56 $Query = $this->Database->query('SELECT * FROM `'.$this->TableUser.'` WHERE `I temId`='.$Row['User'].' ORDER BY `Id` DESC LIMIT 1');56 $Query = $this->Database->query('SELECT * FROM `'.$this->TableUser.'` WHERE `Id`='.$Row['User']); 57 57 $this->User = $Query->fetch_assoc(); 58 58 //print_r($this->User); … … 60 60 } else 61 61 { 62 $Query = $this->Database->select($this->TableUser, '*', "`I temId`=0");62 $Query = $this->Database->select($this->TableUser, '*', "`Id`=0"); 63 63 $this->User = $Query->fetch_assoc(); 64 64 $Result = USER_NOT_LOGGED; … … 139 139 { 140 140 $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()')); 141 $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => $Row['I temId'], 'ItemId' => $Row['ItemId']));141 $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => $Row['Id'], 'Id' => $Row['mId'])); 142 142 // načtení stavu stromu 143 143 $Result = USER_LOGGED_IN;
Note:
See TracChangeset
for help on using the changeset viewer.