Legend:
- Unmodified
- Added
- Removed
-
base.php
r14 r15 4 4 { 5 5 global $Database, $Types, $Config; 6 7 //if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 6 8 7 9 if($Title == '') $Output = '<div>'.$List['Title'].'</div>'; … … 32 34 { 33 35 if($_SESSION['OrderColumn'] == $_GET['OrderColumn']) // Same column => reverse orded 34 $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2; 36 $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2; 35 37 if($_SESSION['OrderTable'] != $List['TableName']) // Different table => set ascending order 36 38 $_SESSION['OrderDirection'] = 0; … … 63 65 } 64 66 } 65 $Output .= '<td><a href="?Action=ViewItem&Table='.$List['TableName'].'&Item='.$DbRow['I d'].'">Zobrazit</a> <a href="?Action=EditItem&Table='.$List['TableName'].'&Item='.$DbRow['Id'].'">Editovat</a> <a href="?Action=DeleteItem&Table='.$List['TableName'].'&Item='.$DbRow['Id'].'">Smazat</a></td></tr>';67 $Output .= '<td><a href="?Action=ViewItem&Table='.$List['TableName'].'&Item='.$DbRow['ItemId'].'">Zobrazit</a> <a href="?Action=EditItem&Table='.$List['TableName'].'&Item='.$DbRow['ItemId'].'">Editovat</a> <a href="?Action=DeleteItem&Table='.$List['TableName'].'&Item='.$DbRow['ItemId'].'">Smazat</a></td></tr>'; 66 68 } 67 69 $Output .= '</table>'; … … 74 76 function ShowHistory($List, $Id, $Title = '') 75 77 { 76 global $Database, $Types, $Config ;78 global $Database, $Types, $Config, $TypeNames; 77 79 78 80 if($Title == '') $Output = '<div>'.$List['Title'].'</div>'; … … 125 127 } 126 128 } 127 $Item = array('Name' => 'Author', 'Type' => 'PointerOneToOne:User'); 128 $ItemType = explode(':', $Item['Type']); 129 echo($TypeNames['PointerOneToUser']); 130 $Item = array('Name' => 'Author', 'Type' => $TypeNames['PointerOneToUser']); 131 $ItemType = explode('|', $Types[$Item['Type']]['Parameters']); 129 132 $Type = $Types[$ItemType[0]]; 130 133 $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); … … 146 149 global $Database, $Types; 147 150 148 $DbResult = $Database->select($List['TableName'], '*', 'I d='.$Id);151 $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1'); 149 152 while($DbRow = $DbResult->fetch_array()) 150 153 { … … 181 184 global $Database, $Types, $System, $LogActionType; 182 185 183 $DbResult = $Database->select($List['TableName'], '*', 'I d='.$Id);186 $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1'); 184 187 while($DbRow = $DbResult->fetch_array()) 185 188 { … … 205 208 $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Edit']); 206 209 $Output = 'Změny uloženy.'; 207 $Output .= ShowViewItem($List, $ NewId);210 $Output .= ShowViewItem($List, $Id); 208 211 $Form->Values['Column'] = $_POST['Column']; 209 212 ExecuteListEvent($List['TableName'], 'OnEdit', $Form->Values); … … 279 282 ); 280 283 $Form->LoadValuesFromForm(); 281 $ System->Modules['DatabaseList']->AddItem($List['TableName'], $Form->Values);284 $NewItemId = $System->Modules['DatabaseList']->AddItem($List['TableName'], $Form->Values); 282 285 $NewId = $Database->insert_id; 283 $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']);286 $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']); 284 287 $Output = 'Položka přidána'; 285 $Output .= ShowViewItem($List, $NewI d);288 $Output .= ShowViewItem($List, $NewItemId); 286 289 $Form->Values['Column'] = $_POST['Column']; 287 290 ExecuteListEvent($List['TableName'], 'OnAdd', $Form->Values); … … 294 297 295 298 $Output = ''; 296 $DbResult = $Database->select($List['TableName'], '*', 'I d='.$Id);299 $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1'); 297 300 while($DbRow = $DbResult->fetch_array()) 298 301 { … … 312 315 ); 313 316 $Output .= $Form->ShowReadOnlyForm(); 314 $Output .= '<a href="?Action=EditItem&Table='.$List['TableName'].'&Item='.$DbRow['I d'].'">Editovat</a> ';317 $Output .= '<a href="?Action=EditItem&Table='.$List['TableName'].'&Item='.$DbRow['ItemId'].'">Editovat</a> '; 315 318 316 319 if(($Column != '') and ($ColumnValue != 0)) … … 328 331 { 329 332 $SubList = $Lists[$Types[$Item['Type']]['Parameters'][0]]; 330 $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['I d'], $Item['TextBefore']).'<br /><br />';333 $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['ItemId'], $Item['TextBefore']).'<br /><br />'; 331 334 } 332 335 } … … 418 421 global $Database, $Lists; 419 422 420 $DbResult = $Database-> select('SystemList', '*');423 $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)'); 421 424 while($DbRow = $DbResult->fetch_assoc()) 422 425 { 423 426 $Items = array(); 424 $DbResult2 = $Database-> select('SystemListItem', '`Id`, `Name`, `TextBefore`, `TextAfter`, `Type`, `Default`, `Help`, `Required`, `Editable`, `VisibleInList`, `VisibleInPointer`', 'List='.$DbRow['Id']);427 $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.List='.$DbRow['ItemId']); 425 428 while($DbRow2 = $DbResult2->fetch_assoc()) 426 429 { … … 437 440 $Lists[$List['TableName']] = $List; 438 441 } 442 //print_r($Lists); 439 443 } 440 444 … … 445 449 $Types = array(); 446 450 $TypeNames = array(); 447 $DbResult = $Database-> select('SystemType', '*');451 $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)'); 448 452 while($DbRow = $DbResult->fetch_assoc()) 449 453 { 450 454 $DbRow['Parameters'] = explode('|', $DbRow['Parameters']); 451 455 $DbRow['BaseType'] = $DbRow['Name']; 452 $Types[$DbRow['I d']] = $DbRow;453 $TypeNames[$DbRow['Name']] = $DbRow['I d'];456 $Types[$DbRow['ItemId']] = $DbRow; 457 $TypeNames[$DbRow['Name']] = $DbRow['ItemId']; 454 458 } 455 459 … … 483 487 //echo($Callback.','); 484 488 if(is_callable($Callback)) return($Callback($Parameters)); 485 else return($Callback );489 else return($Callback.'('.$Type.')'); 486 490 } 487 491 … … 497 501 } 498 502 503 function CheckPermission($Right, $ListId, $ItemId = 0) 504 { 505 global $Database; 506 507 $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['Id'].' ORDER BY User.Id DESC LIMIT 1) ORDER BY PermissionGroup.Id DESC LIMIT 1) AND t1.DeletionTime IS NULL AND t1.List='.$ListId); 508 if($DbResult->num_rows > 0) 509 { 510 $DbRow = $DbResult->fetch_assoc(); 511 switch($DbRow['Right']) 512 { 513 case 0: return(array('Read' => FALSE, 'Write' => FALSE)); 514 case 1: return(array('Read' => TRUE, 'Write' => FALSE)); 515 case 2: return(array('Read' => TRUE, 'Write' => TRUE)); 516 } 517 } 518 } 519 499 520 ?>
Note:
See TracChangeset
for help on using the changeset viewer.