Changeset 895 for trunk/Modules
- Timestamp:
- Jan 12, 2021, 10:29:50 PM (4 years ago)
- Location:
- trunk/Modules
- Files:
-
- 5 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Network/Network.php
r894 r895 184 184 'API' => array('Type' => 'TDeviceAPIType', 'Caption' => 'API', 'Default' => '', 'Null' => true), 185 185 'Logs' => array('Type' => 'TDeviceLogList', 'Caption' => 'Záznamy', 'Default' => ''), 186 'InboundNATPriority' => array('Type' => 'Integer', 'Caption' => 'Priorita příchozího NATu', 'Default' => '1'), 186 187 ), 187 188 'AfterInsert' => array($this, 'AfterInsertNetworkDevice'), -
trunk/Modules/Network/NetworkModels.php
r894 r895 32 32 $Desc->AddString('LoginPassword'); 33 33 $Desc->AddReference('API', DeviceAPIType::GetClassName()); 34 $Desc->AddInteger('InboundNATPriority'); 34 35 return $Desc; 35 36 } -
trunk/Modules/Portal/Portal.php
r893 r895 14 14 $this->Description = 'Community portal.'; 15 15 $this->Dependencies = array('News', 'User'); 16 } 17 18 function GetModels(): array 19 { 20 return array(Panel::GetClassName(), PanelColumn::GetClassName()); 21 } 22 23 function DoInstall(): void 24 { 25 /* $this->Database->query("INSERT INTO `PanelColumn` (`Id`, `Width`) VALUES 26 (1, ''), 27 (2, ''), 28 (3, '70%');"); 29 $this->Database->query("INSERT INTO `Panel` (`Id`, `Module`, `Parameters`, `Order`, `PanelColumn`) VALUES 30 (1, 'ActionGroup', 1, 2, 1), 31 (2, 'ActionGroup', 4, 1, 2), 32 (3, 'ActionGroup', 5, 2, 2), 33 (4, 'ActionGroup', 6, 3, 2), 34 (5, 'ActionGroup', 2, 4, 2), 35 (6, 'ActionGroup', 3, 5, 2), 36 (7, 'NewsGroupList', '', 2, 3), 37 (8, 'Webcam', '', 3, 1), 38 (9, 'UserOptions', '', 1, 3), 39 (10, 'ActionGroup', 9, 1, 1), 40 (11, 'Meteo', '', 4, 1);");*/ 16 41 } 17 42 … … 35 60 )); 36 61 ModuleUser::Cast($this->System->GetModule('User'))->UserPanel[] = array('PagePortal', 'UserPanel'); 62 } 63 } 64 65 class PanelColumn extends Model 66 { 67 static function GetDesc(): ModelDesc 68 { 69 $Desc = new ModelDesc(self::GetClassName()); 70 $Desc->AddString('Width'); 71 return $Desc; 72 } 73 } 74 75 class Panel extends Model 76 { 77 static function GetDesc(): ModelDesc 78 { 79 $Desc = new ModelDesc(self::GetClassName()); 80 $Desc->AddString('Module'); 81 $Desc->AddString('Parameters'); 82 $Desc->AddInteger('Order'); 83 $Desc->AddInteger('PanelColumn'); 84 return $Desc; 37 85 } 38 86 } … … 216 264 217 265 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 218 $DbResult = $this->Database->update('Member', 'Id='.$User->User['Member'], 266 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '. 267 'WHERE `User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']); 268 $CustomerUserRel = $DbResult->fetch_assoc(); 269 $CustomerId = $CustomerUserRel['Member']; 270 271 $DbResult = $this->Database->update('Member', 'Id='.$CustomerId, 219 272 array('FamilyMemberCount' => $Form->Values['FamilyMemberCount'])); 220 $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$ User->User['Member']);273 $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$CustomerId); 221 274 $Member = $DbResult->fetch_assoc(); 222 275 $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'], … … 231 284 'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '. 232 285 'Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '. 233 'ON Subject.Id = Member.Subject WHERE Member.Id='.$ User->User['Member']);286 'ON Subject.Id = Member.Subject WHERE Member.Id='.$CustomerId); 234 287 $DbRow = $DbResult->fetch_array(); 235 288 foreach ($Form->Definition['Items'] as $Index => $Item) -
trunk/Modules/Subject/Subject.php
r894 r895 133 133 function GetModels(): array 134 134 { 135 return array( Country::GetClassName(),Subject::GetClassName(), ContactCategory::GetClassName(),135 return array(Subject::GetClassName(), ContactCategory::GetClassName(), 136 136 Contact::GetClassName()); 137 137 } … … 166 166 } 167 167 168 class Country extends Model169 {170 static function GetDesc(): ModelDesc171 {172 $Desc = new ModelDesc(self::GetClassName());173 $Desc->AddString('Name');174 return $Desc;175 }176 }177 178 168 class Contact extends Model 179 169 { -
trunk/Modules/System/System.php
r894 r895 1 1 <?php 2 3 include_once(dirname(__FILE__).'/SystemModels.php'); 2 4 3 5 class PageModules extends Page … … 109 111 $this->Description = 'Base system module'; 110 112 $this->Dependencies = array(); 113 $this->SystemModule = true; 111 114 } 112 115 … … 115 118 return array(UnitOfMeasure::GetClassName(), ActionIcon::GetClassName(), ActionGroup::GetClassName(), 116 119 ActionType::GetClassName(), Action::GetClassName(), Language::GetClassName(), Country::GetClassName()); 120 } 121 122 function DoBeforeInstall(): void 123 { 124 $this->Manager->OnInstallModel = array($this, 'InstallModel'); 125 $this->Manager->OnUninstallModel = array($this, 'UninstallModel'); 126 } 127 128 function DoAfterUninstall(): void 129 { 130 $this->Manager->OnInstallModel = null; 131 $this->Manager->OnUninstallModel = null; 117 132 } 118 133 … … 184 199 function DoStart(): void 185 200 { 201 $this->Manager->OnInstallModel = array($this, 'InstallModel'); 202 $this->Manager->OnUninstallModel = array($this, 'UninstallModel'); 203 186 204 $this->System->RegisterPage(['module'], 'PageModules'); 187 205 $this->System->FormManager->RegisterClass('Action', array( … … 404 422 //$this->Manager->OnModuleChange = array($this, 'ModuleChange'); 405 423 //$this->LoadFromDatabase(); 424 } 425 426 function InstallModel(ModelDesc $ModelDesc) 427 { 428 $Query = "CREATE TABLE IF NOT EXISTS `".$ModelDesc->Name."` (\n"; 429 $Query .= ' `'.$ModelDesc->PrimaryKey.'` int(11) NOT NULL AUTO_INCREMENT,'."\n"; 430 foreach ($ModelDesc->Columns as $Column) 431 { 432 $Query .= " `".$Column->Name."` "; 433 if ($Column->Type == ModelColumnType::Integer) $Query .= 'int(11)'; 434 else if ($Column->Type == ModelColumnType::String) $Query .= 'varchar(255)'; 435 else if ($Column->Type == ModelColumnType::Float) $Query .= 'varchar(255)'; 436 else if ($Column->Type == ModelColumnType::Text) $Query .= 'text'; 437 else if ($Column->Type == ModelColumnType::DateTime) $Query .= 'datetime'; 438 else if ($Column->Type == ModelColumnType::Reference) $Query .= 'int(11)'; 439 else if ($Column->Type == ModelColumnType::Boolean) $Query .= 'tinyint(1)'; 440 else if ($Column->Type == ModelColumnType::Date) $Query .= 'date'; 441 else if ($Column->Type == ModelColumnType::BigInt) $Query .= 'bigint(20)'; 442 else if ($Column->Type == ModelColumnType::Enum) 443 { 444 $Query .= 'enum("'.implode('", "', $Column->States).'")'; 445 } 446 447 if ($Column->Nullable) $Query .= ''; 448 else $Query .= ' NOT NULL'; 449 450 $Query .= ' COLLATE utf8_general_ci'; 451 452 if ($Column->HasDefault) 453 { 454 if ($Column->Default == null) 455 $Query .= ' DEFAULT NULL'; 456 else $Query .= ' DEFAULT '.$Column->GetDefault(); 457 } 458 $Query .= ",\n"; 459 } 460 $Query .= ' PRIMARY KEY (`'.$ModelDesc->PrimaryKey.'`)'; 461 foreach ($ModelDesc->Columns as $Column) 462 { 463 if ($Column->Type == ModelColumnType::Reference) 464 $Query .= ','."\n".' KEY `'.$Column->Name.'` (`'.$Column->Name.'`)'; 465 else if ($Column->Unique) 466 $Query .= ','."\n".' UNIQUE KEY `'.$Column->Name.'` (`'.$Column->Name.'`)'; 467 } 468 $Query .= "\n"; 469 470 if ($ModelDesc->Memory) $Engine = 'MEMORY'; 471 else $Engine = 'InnoDB'; 472 $Query .= ') ENGINE='.$Engine.' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'; 473 $I = 1; 474 foreach ($ModelDesc->Columns as $Column) 475 { 476 if ($Column->Type == ModelColumnType::Reference) 477 $Query .= "ALTER TABLE `".$ModelDesc->Name."` ". 478 "ADD CONSTRAINT `".$ModelDesc->Name."_ibfk_".$I."` FOREIGN KEY (`".$Column->Name."`) REFERENCES `".$Column->RefTable."` (`Id`);"; 479 $I++; 480 } 481 $this->Database->query($Query); 482 } 483 484 function UninstallModel(ModelDesc $ModelDesc) 485 { 486 $this->Database->query('DROP TABLE IF EXISTS `'.$ModelDesc->Name.'`'); 406 487 } 407 488 … … 544 625 } 545 626 } 546 547 class UnitOfMeasure extends Model548 {549 static function GetDesc(): ModelDesc550 {551 $Desc = new ModelDesc(self::GetClassName());552 $Desc->AddString('Name');553 $Desc->AddString('Unit');554 return $Desc;555 }556 }557 558 class Action extends Model559 {560 static function GetDesc(): ModelDesc561 {562 $Desc = new ModelDesc(self::GetClassName());563 $Desc->AddString('Title');564 $Desc->AddString('URL');565 $Desc->AddReference('Icon', ActionIcon::GetClassName());566 $Desc->AddReference('Type', ActionType::GetClassName());567 $Desc->AddReference('Group', ActionGroup::GetClassName());568 $Desc->AddReference('PermissionOperation', PermissionOperation::GetClassName());569 $Desc->AddBoolean('Enable');570 return $Desc;571 }572 }573 574 class ActionIcon extends Model575 {576 static function GetDesc(): ModelDesc577 {578 $Desc = new ModelDesc(self::GetClassName());579 $Desc->AddString('Name');580 return $Desc;581 }582 }583 584 class ActionGroup extends Model585 {586 static function GetDesc(): ModelDesc587 {588 $Desc = new ModelDesc(self::GetClassName());589 $Desc->AddString('Name');590 return $Desc;591 }592 }593 594 class ActionType extends Model595 {596 static function GetDesc(): ModelDesc597 {598 $Desc = new ModelDesc(self::GetClassName());599 $Desc->AddString('Name');600 return $Desc;601 }602 }603 604 class Language extends Model605 {606 static function GetDesc(): ModelDesc607 {608 $Desc = new ModelDesc(self::GetClassName());609 $Desc->AddString('Name');610 return $Desc;611 }612 }613 614 class Country extends Model615 {616 static function GetDesc(): ModelDesc617 {618 $Desc = new ModelDesc(self::GetClassName());619 $Desc->AddString('Name');620 return $Desc;621 }622 }623 -
trunk/Modules/User/User.php
r894 r895 29 29 } 30 30 31 function DoInstall(): void 32 { 33 $this->Database->insert('PermissionGroup', array('Id' => 1, 'Description' => 'Ostatní')); 34 $this->Database->insert('PermissionGroup', array('Id' => 2, 'Description' => 'Registrovaní uživatelé')); 35 $this->Database->insert('PermissionGroup', array('Id' => 3, 'Description' => 'Zákazníci')); 36 $this->Database->insert('PermissionGroup', array('Id' => 4, 'Description' => 'Správci sítě')); 37 $this->Database->insert('PermissionGroup', array('Id' => 5, 'Description' => 'Systémoví správci')); 38 } 39 31 40 function DoStart(): void 32 41 { … … 181 190 $Output = 'Uživatelů: '.$DbRow['0'].'<br/>'; 182 191 return $Output; 183 }184 185 function DoStop(): void186 {187 192 } 188 193 -
trunk/Modules/User/UserModel.php
r894 r895 75 75 $Desc->AddString('Salt'); 76 76 $Desc->AddString('Email'); 77 $Desc->AddString('LastIpAddress'); 78 $Desc->AddString('LastLoginTime'); 77 $Column = $Desc->AddString('LastIpAddress'); 78 $Column->HasDefault = true; 79 $Column->Nullable = true; 80 $Column = $Desc->AddDateTime('LastLoginTime'); 81 $Column->Nullable = true; 82 $Column->HasDefault = true; 79 83 $Desc->AddDateTime('RegistrationTime'); 80 84 $Desc->AddBoolean('Locked'); 81 $Desc->AddString('InitPassword'); 85 $Column = $Desc->AddString('InitPassword'); 86 $Column->Nullable = true; 87 $Column->HasDefault = true; 82 88 return $Desc; 83 89 } … … 118 124 if ($Row['User'] != '') 119 125 { 120 $Query = $this->Database->query('SELECT `User`.*, `UserCustomerRel`.`Customer` AS `Member` FROM `User` '. 121 ' LEFT JOIN `UserCustomerRel` ON `UserCustomerRel`.`User`=`User`.`Id` WHERE `User`.`Id`='.$Row['User']); 126 $Query = $this->Database->query('SELECT `User`.* FROM `User` WHERE `User`.`Id`='.$Row['User']); 122 127 $this->User = $Query->fetch_assoc(); 123 128 $Result = USER_LOGGED; … … 500 505 { 501 506 $Desc = new ModelDesc(self::GetClassName()); 502 $Desc->AddReference('Module', Module::GetClassName());507 //$Desc->AddReference('Module', Module::GetClassName()); 503 508 $Desc->AddString('Operation'); 504 509 $Desc->AddString('Item'); -
trunk/Modules/User/UserPage.php
r887 r895 21 21 function ShowContacts(): string 22 22 { 23 if (!$this->System->ModuleManager->ModuleRunning('Subject')) return ''; 24 23 25 $Query = 'SELECT `Contact`.`Value`, `Contact`.`Description`, (SELECT `Name` FROM `ContactCategory` WHERE `ContactCategory`.`Id` = `Contact`.`Category`) AS `Category` '. 24 26 'FROM `Contact` WHERE `User` = '. … … 39 41 $Order = GetOrderTableHeader('Contacts', $TableColumns, 'Value', 0); 40 42 $Output .= $Order['Output']; 41 42 43 $Query = $Query.' '.$Order['SQL'].$PageList['SQLLimit']; 43 44 44 $DbResult = $this->Database->query($Query); 45 45 while ($Contact = $DbResult->fetch_assoc()) … … 49 49 '<td>'.$Contact['Value'].'</td>'. 50 50 '<td>'.$Contact['Description'].'</td>'. 51 '</tr>';51 '</tr>'; 52 52 } 53 53 $Output .= '</table>'; -
trunk/Modules/Wiki/Wiki.php
r894 r895 46 46 static function GetDesc(): ModelDesc 47 47 { 48 $Desc = new ModelDesc( 'WikiPage');48 $Desc = new ModelDesc(self::GetClassName()); 49 49 $Desc->AddString('Name'); 50 50 $Desc->AddString('NormalizedName');
Note:
See TracChangeset
for help on using the changeset viewer.