Changeset 887 for trunk/Modules/EmailQueue/EmailQueue.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/EmailQueue/EmailQueue.php
r882 r887 3 3 class PageEmailQueueProcess extends Page 4 4 { 5 var $FullTitle = 'Odeslání pošty z fronty'; 6 var $ShortTitle = 'Fronta pošty'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Odeslání pošty z fronty'; 9 $this->ShortTitle = 'Fronta pošty'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process();15 $Output = ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->Process(); 12 16 $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output; 13 17 return $Output; … … 17 21 class ModuleEmailQueue extends AppModule 18 22 { 19 function __construct( $System)23 function __construct(System $System) 20 24 { 21 25 parent::__construct($System); … … 28 32 } 29 33 30 function DoInstall() 34 function DoInstall(): void 31 35 { 32 36 } 33 37 34 function DoUninstall() 38 function DoUninstall(): void 35 39 { 36 40 } 37 41 38 function DoStart() 42 function DoStart(): void 39 43 { 40 $this->System->RegisterPage( 'fronta-posty', 'PageEmailQueueProcess');44 $this->System->RegisterPage(['fronta-posty'], 'PageEmailQueueProcess'); 41 45 $this->System->FormManager->RegisterClass('Email', array( 42 46 'Title' => 'Nový email', … … 70 74 } 71 75 72 function DoStop() 76 function DoStop(): void 73 77 { 74 78 } … … 83 87 } 84 88 85 function Process() 89 function Process(): string 86 90 { 87 91 $Output = ''; … … 103 107 $Mail->Send(); 104 108 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 105 $this->System->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']);109 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('System', 'SendEmail', $DbRow['Id']); 106 110 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 107 111 } 108 112 return $Output; 109 113 } 114 115 static function Cast(AppModule $AppModule): ModuleEmailQueue 116 { 117 if ($AppModule instanceof ModuleEmailQueue) 118 { 119 return $AppModule; 120 } 121 throw new Exception('Expected ModuleEmailQueue type but '.gettype($AppModule)); 122 } 110 123 } 111
Note:
See TracChangeset
for help on using the changeset viewer.