'.$List['Title'].''; else $Output = '
'.$Title.'
'; $Output .= ''; foreach($List['Items'] as $Item) { if(($Item['VisibleInList'] == 1) and ($Item['Name'] != $Column)) $Output .= ''; } $Output .= ''; $Where = '1'; if(($Column != '') and ($ColumnValue != 0)) { $Where .= ' AND ('.$Column.'='.$ColumnValue.')'; $ColumnSelection = '&Column='.$Column.'&ColumnValue='.$ColumnValue; $FullListLink = 'Celkový seznam'; } else { $ColumnSelection = ''; $FullListLink = ''; } if($Filter != '') $Where .= ' AND '.$Filter; // Handle ordering if(array_key_exists('OrderColumn', $_GET)) { if(array_key_exists('OrderTable', $_SESSION) and ($_SESSION['OrderTable'] != $List['Id'])) // Different table => set ascending order $_SESSION['OrderDirection'] = 0; $_SESSION['OrderColumn'] = $_GET['OrderColumn']; $_SESSION['OrderTable'] = $List['Id']; $_SESSION['OrderDirection'] = $_GET['OrderDirection']; } //echo(';'.$_SESSION['OrderTable'].','.$_SESSION['OrderColumn']); if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['Id'])) { $OrderDirection = array('ASC', 'DESC'); $Order = 'ORDER BY `'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']]; } else $Order = ''; if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))'; $Where .= ' '.$Order; $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM '.GetListTableName($List).' WHERE '.$Where); $DbRow = $DbResult->fetch_row(); $TotalItemCount = $DbRow[0]; $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']); //echo($Database->LastQuery); while($DbRow = $DbResult->fetch_assoc()) { $Output .= ''; foreach($List['Items'] as $Index => $Item) { if(($Item['VisibleInList'] == 1) and ($Item['Name'] != $Column)) { $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); $Output .= ''; } } $Output .= ''; } $Output .= '
'.$Item['TextBefore'].'Akce
'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).''; if(CheckPermission('Read', $List['Id'])) $Output .= 'Zobrazit'; if(CheckPermission('Write', $List['Id'])) $Output .= ' Editovat'; if(CheckPermission('Write', $List['Id'])) $Output .= ' Smazat'; $Output .= '
'; $PageList = PagesList($Page, $TotalItemCount); if(strlen($PageList) != 0) $Output .= $PageList.'
'; if(CheckPermission('Write', $List['Id'])) $Output .= ' Přidat '.$FullListLink; if(CheckPermission('Read', $List['Id'])) $Output .= ' Hledat '.$FullListLink; return($Output); } /* function ShowHistory($List, $Id, $Title = '') { global $Database, $Config; if($Title == '') $Output = '
'.$List['Title'].'
'; else $Output = '
'.$Title.'
'; $Output .= ''; foreach($List['Items'] as $Item) { if($Item['VisibleInList'] == 1) $Output .= ''; } $Output .= ''; $Where = ' AND (ItemId='.$Id.')'; // Handle ordering if(array_key_exists('OrderColumn', $_GET)) { if($_SESSION['OrderColumn'] == $_GET['OrderColumn']) // Same column => reverse orded $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2; if($_SESSION['OrderTable'] != $List['ItemId']) // Different table => set ascending order $_SESSION['OrderDirection'] = 0; $_SESSION['OrderColumn'] = $_GET['OrderColumn']; $_SESSION['OrderTable'] = $List['ItemId']; } if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['ItemId'])) { $OrderDirection = array('ASC', 'DESC'); $Order = 'ORDER BY t1.`'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']]; } else $Order = ''; if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))'; $Where .= ' '.$Order; $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'); //echo($Database->LastQuery.'
'); $DbRow = $DbResult->fetch_row(); $TotalItemCount = $DbRow[0]; $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'` AS t1 WHERE 1'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']); //echo($Database->LastQuery.'
'); while($DbRow = $DbResult->fetch_assoc()) { $Output .= ''; foreach($List['Items'] as $Item) { if($Item['VisibleInList'] == 1) { $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['ItemId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); $Output .= ''; } } $Item = array('Name' => 'Author', 'Type' => TypePointerToUserId); $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['ItemId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']); $Output .= ''; $Output .= ''; $Output .= ''; } $Output .= '
'.$Item['TextBefore'].'AutorČas vytvořeníČas odstraněníAkce
'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).''.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).''.$DbRow['CreationTime'].''.$DbRow['DeletionTime'].'Zobrazit
'; $Output .= PagesList($Page, $TotalItemCount); $Output .= ' Celkový seznam'; return($Output); } */ function ShowEditItem($List, $Id) { global $Database; if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); while($DbRow = $DbResult->fetch_assoc()) { $DefinitionItems = array(); foreach($List['Items'] as $Index => $Item) { $Type = GetTypeDefinition($Item['Type']); if($Type['BaseType'] != 'PointerOneToMany') { if($Item['Required'] == 1) $Required = '*'; else $Required = ''; if($Item['Editable'] == 1) { $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); } else $DefinitionItems[] = array('Name' => $Index, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $DbRow[$Index]); } } } $Form = new Form(); $Form->Definition = array ( 'Title' => '', 'SubmitButtonText' => 'Uložit', 'Items' => $DefinitionItems, ); $Form->OnSubmit = '?Action=EditItemFinish&Item='.$Id; $Output = $Form->ShowEditForm(); if(array_key_exists('Column', $_GET)) $Column = $_GET['Column']; else $Column = ''; if(array_key_exists('ColumnValue', $_GET)) $ColumnValue = $_GET['ColumnValue']; else $ColumnValue = ''; if(($Column != '') and ($ColumnValue != 0)) { $Output .= 'Celkový seznam'; } else { $Output .= 'Celkový seznam'; } return($Output); } function ShowEditItemFinish($List, $Id) { global $Database, $System, $LogActionType; if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); while($DbRow = $DbResult->fetch_assoc()) { $DefinitionItems = array(); foreach($List['Items'] as $Index => $Item) { $Type = GetTypeDefinition($Item['Type']); if($Type['BaseType'] != 'PointerOneToMany') { if($Item['Editable'] == 1) { $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); } else $DefinitionItems[] = array('Name' => $Index, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $DbRow[$Index]); } } } $Form = new Form(); $Form->Definition = array ( 'Title' => '', 'SubmitButtonText' => 'Uložit', 'Items' => $DefinitionItems, ); $Form->LoadValuesFromForm(); $System->Modules['DatabaseList']->EditItem($List['Id'], $Form->Values, $Id); $NewId = $Database->insert_id; $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Edit']); $Output = 'Změny uloženy.'; $Output .= ShowViewItem($List, $Id); if(array_key_exists('Column', $_POST)) $Form->Values['Column'] = $_POST['Column']; else $Form->Values['Column'] = ''; $Form->Values['Id'] = $Id; $Form->Values['ListTableName'] = $List['TableName']; $Form->Values['ListDatabaseName'] = $List['Database']; ExecuteListEvent($List['Id'], 'OnEdit', $Form->Values); return($Output); } function ShowAddItem($List, $Column = '', $ColumnValue = 0) { global $Database; if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); $DefinitionItems = array(); $AfterTableOutput = ''; foreach($List['Items'] as $Item) { //echo($Item['Name'].','); $Type = GetTypeDefinition($Item['Type']); if(($Type['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) { if($Item['Required'] == 1) $Required = '*'; else $Required = ''; if($Item['Editable'] == 1) $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['Id'], 'SourceItemId' => 0); } else if($Item['Name'] == $Column) { $DefinitionItems[] = array('Name' => $Column, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $ColumnValue); } } $DefinitionItems[] = array('Name' => 'Column', 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $Column); $Form = new Form(); $Form->Definition = array ( 'Title' => '', 'SubmitButtonText' => 'Přidat', 'Items' => $DefinitionItems, ); $Form->OnSubmit = '?Action=AddItemFinish'; $Output = $Form->ShowEditForm().$AfterTableOutput; if(($Column != '') and ($ColumnValue != 0)) { $Output .= 'Celkový seznam'; } else { $Output .= 'Celkový seznam'; } return($Output); } function ShowAddItemFinish($List) { global $Database, $System, $LogActionType; if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); $DefinitionItems = array(); $AfterTableOutput = ''; if(array_key_exists('Column', $_GET)) $Column = $_GET['Column']; else $Column = ''; foreach($List['Items'] as $Item) { //echo($Item['Name'].','); $Type = GetTypeDefinition($Item['Type']); if(($Type['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) { if($Item['Required'] == 1) $Required = '*'; else $Required = ''; $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['Id'], 'SourceItemId' => 0); } else if($Item['Name'] == $Column) { $DefinitionItems[] = array('Name' => $Column, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $ColumnValue); } } $Form = new Form(); $Form->Definition = array ( 'Title' => '', 'SubmitButtonText' => 'Přidat', 'Items' => $DefinitionItems, ); $Form->LoadValuesFromForm(); $NewItemId = $System->Modules['DatabaseList']->AddItem($List['Id'], $Form->Values); $NewId = $Database->insert_id; $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']); $Output = 'Položka přidána'; $Output .= ShowViewItem($List, $NewItemId); $Form->Values['Column'] = $_POST['Column']; ExecuteListEvent($List['Id'], 'OnAdd', $Form->Values); return($Output); } function ShowViewItem($List, $Id, $Column = '', $ColumnValue = 0) { global $Database; if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); $Output = ''; $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); while($DbRow = $DbResult->fetch_assoc()) { $DefinitionItems = array(); $Required = ''; foreach($List['Items'] as $Index => $Item) { $Type = GetTypeDefinition($Item['Type']); if($Type['BaseType'] != 'PointerOneToMany') { $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0); } } $Form = new Form(); $Form->Definition = array ( 'Title' => '', 'Items' => $DefinitionItems, ); $Output .= $Form->ShowReadOnlyForm(); if(CheckPermission('Write', $List['Id'])) $Output .= 'Editovat '; if(($Column != '') and ($ColumnValue != 0)) { $Output .= 'Celkový seznam'; } else { $Output .= 'Celkový seznam'; } $Output .= ' Historie'; $Output .= ' Smazat'; $Output .= '
'; foreach($List['Items'] as $Index => $Item) { $Type = GetTypeDefinition($Item['Type']); if($Type['BaseType'] == 'PointerOneToMany') { $SubList = GetListDefinition($Type['Parameters'][0]); $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow[$List['IdName']], $Item['TextBefore']).'

'; } } } return($Output); } function ShowDeleteItem($List, $Id) { global $Database, $System, $LogActionType; if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); $System->Modules['Log']->Add($List['Id'], $Id, $LogActionType['Delete']); $System->Modules['DatabaseList']->DeleteItem($List['Id'], $Id); $Output = 'Položka smazána.'; $Output .= ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']).'

'; ExecuteListEvent($List['Id'], 'OnDelete', $Id); return($Output); } function ShowSearch($List) { global $Database; if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); $DefinitionItems = array(); $AfterTableOutput = ''; if(array_key_exists('Column', $_GET)) $Column = $_GET['Column']; else $Column = ''; foreach($List['Items'] as $Item) { //echo($Item['Name'].','); $Type = GetTypeDefinition($Item['Type']); if(($Type['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) { if($Item['Editable'] == 1) $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => '', 'SourceTable' => $List['Id'], 'SourceItemId' => 0); } else if($Item['Name'] == $Column) { $DefinitionItems[] = array('Name' => $Column, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $ColumnValue); } } $DefinitionItems[] = array('Name' => 'Column', 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $Column); $Form = new Form(); $Form->Definition = array ( 'Title' => 'Hledání', 'SubmitButtonText' => 'Vyhledat', 'Items' => $DefinitionItems, ); $Form->OnSubmit = '?Action=Search'; $Output = $Form->ShowEditForm(); return($Output); } function Search($List) { global $Database, $System, $LogActionType; if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); $DefinitionItems = array(); $AfterTableOutput = ''; if(array_key_exists('Column', $_GET)) $Column = $_GET['Column']; else $Column = ''; foreach($List['Items'] as $Item) { //echo($Item['Name'].','); $Type = GetTypeDefinition($Item['Type']); if(($Type['BaseType'] != 'PointerOneToMany') and ($Item['Name'] != $Column)) { if($Item['Required'] == 1) $Required = '*'; else $Required = ''; $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['Id'], 'SourceItemId' => 0); } else if($Item['Name'] == $Column) { $DefinitionItems[] = array('Name' => $Column, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $ColumnValue); } } $Form = new Form(); $Form->Definition = array ( 'Title' => '', 'SubmitButtonText' => 'Přidat', 'Items' => $DefinitionItems, ); $Form->LoadValuesFromForm(); $Filter = '1'; print_r($Form); foreach($Form->Definition['Items'] as $Item) { //if($Item['Editable'] == 1) { //echo($Item['Name'].','); $Type = GetTypeDefinition($Item['Type']); $TypeObject = $Type['Class']; $Filter .= ' AND (`'.$Item['Name'].'` LIKE '.$TypeObject->DatabaseEscape($Form->Values[$Item['Name']]).')'; } } echo('d'.$Filter.'d'); $Output = ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue'], '', $Filter).'

'; return($Output); } function ShowMenu() { global $Database; $Output = ''; $DbResult = $Database->query('SELECT * FROM `SystemMenu`'); while($DbRow = $DbResult->fetch_assoc()) { $Group = ''; $DbResult2 = $Database->query('SELECT * FROM `SystemList` WHERE `Menu` = '.$DbRow['Id']); while($DbRow2 = $DbResult2->fetch_assoc()) { $List = GetListDefinition($DbRow2['Id']); if(CheckPermission('Read', $DbRow2[$List['IdName']])) $Group .= ''.$DbRow2['Title'].'
'; } if($Group != '') $Output .= ''.$DbRow['Name'].'
'.$Group.'
'; } $Output .= '
'; return($Output); } function Output() { //print_r($_SESSION); $PermanentVar = array('Table', 'Item', 'Column', 'ColumnValue', 'Action'); if(array_key_exists('Table', $_GET)) if($_GET['Table'] != $_SESSION['Table']) { $_SESSION['Column'] = ''; $_SESSION['ColumnValue'] = ''; } foreach($PermanentVar as $Var) { if(array_key_exists($Var, $_GET)) $_SESSION[$Var] = $_GET[$Var]; } $Output = ''; if(array_key_exists('Table', $_SESSION) and ($_SESSION['Table'] != '')) { $List = GetListDefinition($_SESSION['Table']); if(is_null($List)) $Output .= SystemMessage('Zobrazení stránky', 'Seznam id '.$_SESSION['Table'].' nenalezen!'); else if(array_key_exists('Action', $_SESSION)) { switch($_SESSION['Action']) { case 'ShowSearch': $Output = ShowSearch($List); break; case 'Search': $Output = Search($List); break; case 'EditItem': $Output = ShowEditItem($List, $_SESSION['Item']); break; case 'EditItemFinish': $Output = ShowEditItemFinish($List, $_SESSION['Item']); break; case 'DeleteItem': $Output = ShowDeleteItem($List, $_SESSION['Item']); break; case 'ViewItem': $Output = ShowViewItem($List, $_SESSION['Item'], $_SESSION['Column'], $_SESSION['ColumnValue']); break; case 'AddItem': $Output = ShowAddItem($List, $_SESSION['Column'], $_SESSION['ColumnValue']); break; case 'AddItemFinish': $Output = ShowAddItemFinish($List); break; case 'ShowHistory': $Output = ShowHistory($List, $_SESSION['Item']); break; case 'ShowList': default: $Output = ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']); } } else $Output = ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']); } return($Output); } function GetListDefinition($Id) { global $Database, $Lists; if(!array_key_exists($Id, $Lists)) { $DbResult = $Database->query('SELECT * FROM `SystemList` WHERE `Id`='.$Id); if($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $Items = array(); $DbResult2 = $Database->query('SELECT * FROM `SystemListItem` WHERE `List`='.$DbRow['Id'].' ORDER BY `Sequence`'); while($DbRow2 = $DbResult2->fetch_assoc()) { $Items[$DbRow2['Name']] = $DbRow2; } $List = array( 'Id' => $DbRow['Id'], 'TableName' => $DbRow['TableName'], 'Database' => $DbRow['Database'], 'Title' => $DbRow['Title'], 'IdName' => $DbRow['IdName'], 'Items' => $Items, ); //if(!array_key_exists($List['ItemId'], $TypeDefinitionList)) { $ClassName = 'List'.$DbRow['TableName']; if(class_exists($ClassName)) $List['Class'] = new $ClassName; } $Lists[$List['Id']] = $List; } else { $Lists[$Id] = NULL; } } return($Lists[$Id]); //print_r($Lists); } function GetTypeDefinition($Id) { global $Database, $Types, $TypeDefinitionList; if(!array_key_exists($Id, $Types)) { $DbResult = $Database->query('SELECT * FROM `SystemType` WHERE `Id`='.$Id); if($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); $DbRow['Parameters'] = explode('|', $DbRow['Parameters']); if(($DbRow['ParentType'] == TypePointerOneToOneId) or ($DbRow['ParentType'] == TypePointerOneToManyId)) { $DbResult2 = $Database->query('SELECT * FROM `SystemList` WHERE `TableName`="'.$DbRow['Parameters'][0].'"'); $DbRow2 = $DbResult2->fetch_assoc(); //echo($DbRow['ParentType'].'-'.$DbRow['Parameters'][0].'='.$DbRow2['ItemId'].'
'); $DbRow['Parameters'][0] = $DbRow2['Id']; } $DbRow['BaseType'] = $DbRow['Name']; // Merge parent type definition if($DbRow['ParentType'] != 0) { $ParentType = GetTypeDefinition($DbRow['ParentType']); foreach($DbRow as $Index => $Item) if($Item == '') { $DbRow[$Index] = $ParentType[$Index]; } $DbRow['BaseType'] = $ParentType['Name']; } if(!array_key_exists($DbRow['BaseType'], $TypeDefinitionList)) { $ClassName = 'Type'.$DbRow['BaseType']; $TypeDefinitionList[$DbRow['BaseType']] = new $ClassName; } $DbRow['Class'] = &$TypeDefinitionList[$DbRow['BaseType']]; $Types[$DbRow['Id']] = $DbRow; } else $Types[$DbRow['Id']] = NULL; } //print_r($Types); return($Types[$Id]); } function ExecuteListEvent($Table, $Event, $Parameters) { $ListDefinition = GetListDefinition($Table); if(array_key_exists('Class', $ListDefinition)) { $ListObject = $ListDefinition['Class']; if(is_callable(array($ListObject, $Event))) return($ListObject->$Event($Parameters)); else return($ListDefinition['TableName'].'->'.$Event.'('.$Table.')'); } else return($ListDefinition['TableName'].'->'.$Event.'('.$Table.')'); } function ExecuteTypeEvent($Type, $Event, $Parameters) { $TypeDefinition = GetTypeDefinition($Type); $TypeObject = $TypeDefinition['Class']; if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters)); else return($TypeDefinition['BaseType'].'->'.$Event.'('.$Type.')'); } function ModifyAllTables($Query) { global $Database; $DbResult = $Database->select(array('Table' => 'SystemList')); while($DbRow = $DbResult->fetch_assoc()) { $Database->query($Query); } } function CheckPermission($Right, $ListId, $ItemId = 0) { global $Database, $System; $Result = FALSE; return(TRUE); $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); if($DbResult->num_rows > 0) { $DbRow = $DbResult->fetch_assoc(); switch($DbRow['Right']) { case 0: $Privileges = array('Read' => FALSE, 'Write' => FALSE); break; case 1: $Privileges = array('Read' => TRUE, 'Write' => FALSE); break; case 2: $Privileges = array('Read' => TRUE, 'Write' => TRUE); break; } $Result = $Privileges[$Right]; } //print_r($Privileges); //echo($DbRow['Right'].' '.$Result.'
'); return($Result); } ?>