| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | include_once(dirname(__FILE__).'/SystemModels.php');
|
|---|
| 4 |
|
|---|
| 5 | class ModuleSystem extends Module
|
|---|
| 6 | {
|
|---|
| 7 | public bool $InstalledChecked;
|
|---|
| 8 |
|
|---|
| 9 | function __construct(System $System)
|
|---|
| 10 | {
|
|---|
| 11 | parent::__construct($System);
|
|---|
| 12 | $this->Name = 'System';
|
|---|
| 13 | $this->Version = '1.0';
|
|---|
| 14 | $this->Creator = 'Chronos';
|
|---|
| 15 | $this->License = 'GNU/GPLv3';
|
|---|
| 16 | $this->Description = 'Base system module';
|
|---|
| 17 | $this->Type = ModuleType::System;
|
|---|
| 18 | $this->Dependencies = array(ModuleModuleManager::GetName());
|
|---|
| 19 | $this->Models = array(UnitOfMeasure::GetClassName(), ActionIcon::GetClassName(), ActionGroup::GetClassName(),
|
|---|
| 20 | ActionType::GetClassName(), Action::GetClassName(), Language::GetClassName(), Country::GetClassName());
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | function DoStart(): void
|
|---|
| 24 | {
|
|---|
| 25 | $this->System->FormManager->RegisterClass('Action', array(
|
|---|
| 26 | 'Title' => 'Akce',
|
|---|
| 27 | 'Table' => 'Action',
|
|---|
| 28 | 'Items' => array(
|
|---|
| 29 | //'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
|---|
| 30 | 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
|---|
| 31 | 'URL' => array('Type' => 'Hyperlink', 'Caption' => 'Odkaz', 'Default' => ''),
|
|---|
| 32 | 'Icon' => array('Type' => 'TActionIcon', 'Caption' => 'Ikony', 'Default' => '', 'Null' => true),
|
|---|
| 33 | 'Type' => array('Type' => 'TActionType', 'Caption' => 'Typ', 'Default' => ''),
|
|---|
| 34 | 'Group' => array('Type' => 'TActionGroup', 'Caption' => 'Skupina', 'Default' => '', 'Null' => true),
|
|---|
| 35 | 'PermissionOperation' => array('Type' => 'TPermissionOperation', 'Caption' => 'Operace oprávnění', 'Default' => ''),
|
|---|
| 36 | 'Enable' => array('Type' => 'Boolean', 'Caption' => 'Povolení', 'Default' => ''),
|
|---|
| 37 | ),
|
|---|
| 38 | ));
|
|---|
| 39 | $this->System->FormManager->RegisterClass('ActionIcon', array(
|
|---|
| 40 | 'Title' => 'Ikony akcí',
|
|---|
| 41 | 'Table' => 'ActionIcon',
|
|---|
| 42 | 'Items' => array(
|
|---|
| 43 | 'Name' => array('Type' => 'Image', 'Caption' => 'Název souboru', 'Default' => ''),
|
|---|
| 44 | 'Items' => array('Type' => 'TActionListIcon', 'Caption' => 'Položky', 'Default' => ''),
|
|---|
| 45 | ),
|
|---|
| 46 | ));
|
|---|
| 47 | $this->System->FormManager->RegisterClass('ActionGroup', array(
|
|---|
| 48 | 'Title' => 'Skupiny akcí',
|
|---|
| 49 | 'Table' => 'ActionGroup',
|
|---|
| 50 | 'Items' => array(
|
|---|
| 51 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
|---|
| 52 | 'Items' => array('Type' => 'TActionListGroup', 'Caption' => 'Položky', 'Default' => ''),
|
|---|
| 53 | ),
|
|---|
| 54 | ));
|
|---|
| 55 | $this->System->FormManager->RegisterClass('ActionType', array(
|
|---|
| 56 | 'Title' => 'Typy akcí',
|
|---|
| 57 | 'Table' => 'ActionType',
|
|---|
| 58 | 'Items' => array(
|
|---|
| 59 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
|---|
| 60 | 'Items' => array('Type' => 'TActionListType', 'Caption' => 'Položky', 'Default' => ''),
|
|---|
| 61 | ),
|
|---|
| 62 | ));
|
|---|
| 63 | $this->System->FormManager->RegisterClass('Language', array(
|
|---|
| 64 | 'Title' => 'Jazyky',
|
|---|
| 65 | 'Table' => 'Language',
|
|---|
| 66 | 'DefaultSortColumn' => 'Name',
|
|---|
| 67 | 'Items' => array(
|
|---|
| 68 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
|---|
| 69 | ),
|
|---|
| 70 | ));
|
|---|
| 71 | $this->System->FormManager->RegisterClass('UnitOfMeasure', array(
|
|---|
| 72 | 'Title' => 'Měrné jednotky',
|
|---|
| 73 | 'Table' => 'UnitOfMeasure',
|
|---|
| 74 | 'DefaultSortColumn' => 'Name',
|
|---|
| 75 | 'Items' => array(
|
|---|
| 76 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
|---|
| 77 | 'Unit' => array('Type' => 'String', 'Caption' => 'Jednotka', 'Default' => ''),
|
|---|
| 78 | ),
|
|---|
| 79 | ));
|
|---|
| 80 | $this->System->FormManager->RegisterClass('Country', array(
|
|---|
| 81 | 'Title' => 'Země',
|
|---|
| 82 | 'Table' => 'Country',
|
|---|
| 83 | 'DefaultSortColumn' => 'Name',
|
|---|
| 84 | 'Items' => array(
|
|---|
| 85 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
|---|
| 86 | ),
|
|---|
| 87 | ));
|
|---|
| 88 | $this->System->FormManager->RegisterFormType('TCountry', array(
|
|---|
| 89 | 'Type' => 'Reference',
|
|---|
| 90 | 'Table' => 'Country',
|
|---|
| 91 | 'Id' => 'Id',
|
|---|
| 92 | 'Name' => 'Name',
|
|---|
| 93 | 'Filter' => '1',
|
|---|
| 94 | ));
|
|---|
| 95 | $this->System->FormManager->RegisterFormType('TUnitOfMeasure', array(
|
|---|
| 96 | 'Type' => 'Reference',
|
|---|
| 97 | 'Table' => 'UnitOfMeasure',
|
|---|
| 98 | 'Id' => 'Id',
|
|---|
| 99 | 'Name' => 'Name',
|
|---|
| 100 | 'Filter' => '1',
|
|---|
| 101 | ));
|
|---|
| 102 | $this->System->FormManager->RegisterFormType('TLanguage', array(
|
|---|
| 103 | 'Type' => 'Reference',
|
|---|
| 104 | 'Table' => 'Language',
|
|---|
| 105 | 'Id' => 'Id',
|
|---|
| 106 | 'Name' => 'Name',
|
|---|
| 107 | 'Filter' => '1',
|
|---|
| 108 | ));
|
|---|
| 109 | $this->System->FormManager->RegisterFormType('TAction', array(
|
|---|
| 110 | 'Type' => 'Reference',
|
|---|
| 111 | 'Table' => 'Action',
|
|---|
| 112 | 'Id' => 'Id',
|
|---|
| 113 | 'Name' => 'Title',
|
|---|
| 114 | 'Filter' => '1',
|
|---|
| 115 | ));
|
|---|
| 116 | $this->System->FormManager->RegisterFormType('TActionIcon', array(
|
|---|
| 117 | 'Type' => 'Reference',
|
|---|
| 118 | 'Table' => 'ActionIcon',
|
|---|
| 119 | 'Id' => 'Id',
|
|---|
| 120 | 'Name' => 'Name',
|
|---|
| 121 | 'Filter' => '1',
|
|---|
| 122 | ));
|
|---|
| 123 | $this->System->FormManager->RegisterFormType('TActionType', array(
|
|---|
| 124 | 'Type' => 'Reference',
|
|---|
| 125 | 'Table' => 'ActionType',
|
|---|
| 126 | 'Id' => 'Id',
|
|---|
| 127 | 'Name' => 'Name',
|
|---|
| 128 | 'Filter' => '1',
|
|---|
| 129 | ));
|
|---|
| 130 | $this->System->FormManager->RegisterFormType('TActionGroup', array(
|
|---|
| 131 | 'Type' => 'Reference',
|
|---|
| 132 | 'Table' => 'ActionGroup',
|
|---|
| 133 | 'Id' => 'Id',
|
|---|
| 134 | 'Name' => 'Name',
|
|---|
| 135 | 'Filter' => '1',
|
|---|
| 136 | ));
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | static function Cast(Module $Module): ModuleSystem
|
|---|
| 140 | {
|
|---|
| 141 | if ($Module instanceof ModuleSystem)
|
|---|
| 142 | {
|
|---|
| 143 | return $Module;
|
|---|
| 144 | }
|
|---|
| 145 | throw new Exception('Expected ModuleSystem type but got '.gettype($Module));
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | function ShowAction(string $Id): string
|
|---|
| 149 | {
|
|---|
| 150 | $Output = '';
|
|---|
| 151 | $DbResult = $this->Database->query('SELECT *, `ActionIcon`.`Name` AS `Icon` FROM `Action` '.
|
|---|
| 152 | 'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
|
|---|
| 153 | 'WHERE (`Action`.`Id`='.$Id.')');
|
|---|
| 154 | if ($DbResult->num_rows > 0)
|
|---|
| 155 | {
|
|---|
| 156 | $Action = $DbResult->fetch_assoc();
|
|---|
| 157 | if ($Action['Icon'] == '') $Action['Icon'] = 'clear.png';
|
|---|
| 158 | if (substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = Core::Cast($this->System)->Link($Action['URL']);
|
|---|
| 159 | if (!defined('NEW_PERMISSION') or ModuleUser::Cast(Core::Cast($this->System)->GetModule('User'))->User->CheckPermission('System', 'Read', 'Item', $Id))
|
|---|
| 160 | $Output .= '<img alt="'.$Action['Title'].'" src="'.Core::Cast($this->System)->Link('/images/favicons/'.$Action['Icon']).
|
|---|
| 161 | '" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a>';
|
|---|
| 162 | }
|
|---|
| 163 | return $Output;
|
|---|
| 164 | }
|
|---|
| 165 | }
|
|---|