Changeset 887 for trunk/Modules/User/User.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/User.php
r874 r887 7 7 class ModuleUser extends AppModule 8 8 { 9 var $UserPanel; 10 11 function __construct($System) 9 public array $UserPanel; 10 public User $User; 11 12 function __construct(System $System) 12 13 { 13 14 parent::__construct($System); … … 19 20 $this->Dependencies = array(); 20 21 $this->UserPanel = array(); 21 } 22 23 function DoInstall() 22 $this->User = new User($System); 23 } 24 25 function DoInstall(): void 24 26 { 25 27 $this->Database->query("CREATE TABLE IF NOT EXISTS `User` ( … … 108 110 } 109 111 110 function DoUninstall() 112 function DoUninstall(): void 111 113 { 112 114 $this->Database->query('DROP TABLE `PermissionUserAssignment`'); … … 118 120 } 119 121 120 function DoUpgrade() 122 function DoUpgrade(): void 121 123 { 122 124 /* … … 129 131 } 130 132 131 function DoStart() 132 { 133 $this->System->User = new User($this->System); 134 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check(); 135 $this->System->RegisterPage('userlist', 'PageUserList'); 136 $this->System->RegisterPage('user', 'PageUser'); 133 function DoStart(): void 134 { 135 if (isset($_SERVER['REMOTE_ADDR'])) $this->User->Check(); 136 $this->System->RegisterPage(['userlist'], 'PageUserList'); 137 $this->System->RegisterPage(['user'], 'PageUser'); 137 138 $this->System->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback')); 138 139 $this->System->FormManager->RegisterClass('UserLogin', array( … … 272 273 'Filter' => '1', 273 274 )); 274 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('User',275 array('ModuleUser', 'ShowDashboardItem'));276 } 277 278 function ShowDashboardItem() 275 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('User', 276 array($this, 'ShowDashboardItem')); 277 } 278 279 function ShowDashboardItem(): string 279 280 { 280 281 $DbResult = $this->Database->select('User', 'COUNT(*)', '1'); … … 284 285 } 285 286 286 function DoStop() 287 { 288 } 289 290 function TopBarCallback() 291 { 292 if ($this-> System->User->User['Id'] == null)287 function DoStop(): void 288 { 289 } 290 291 function TopBarCallback(): string 292 { 293 if ($this->User->User['Id'] == null) 293 294 { 294 295 $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '. … … 296 297 } else 297 298 { 298 $Output = $this-> System->User->User['Name'].299 $Output = $this->User->User['Name']. 299 300 ' <a href="'.$this->System->Link('/user/?Action=UserMenu').'">Nabídka</a>'. 300 301 ' <a href="'.$this->System->Link('/user/?Action=Logout').'">Odhlásit</a>'; … … 303 304 return $Output; 304 305 } 306 307 static function Cast(AppModule $AppModule): ModuleUser 308 { 309 if ($AppModule instanceof ModuleUser) 310 { 311 return $AppModule; 312 } 313 throw new Exception('Expected ModuleUser type but got '.gettype($AppModule)); 314 } 305 315 }
Note:
See TracChangeset
for help on using the changeset viewer.