Name = 'User'; $this->Version = '1.1'; $this->Creator = 'Chronos'; $this->License = 'GNU/GPL'; $this->Description = 'User and permission management'; $this->Dependencies = array(); $this->User = new User($this->System); } function DoStart(): void { $this->System->RegisterPage(['users'], 'PageUserList'); $this->System->RegisterPage(['options'], 'PageUserOptions'); $this->System->RegisterPage(['registration'], 'PageUserRegistration'); $this->System->RegisterPage(['user'], 'PageUserProfile'); $this->System->RegisterPage(['login'], 'PageUserLogin'); Core::Cast($this->System)->RegisterMenuItem(array( 'Title' => T('Translators'), 'Hint' => 'Seznam registrovaných uživatelů', 'Link' => $this->System->Link('/users/'), 'Permission' => LICENCE_ANONYMOUS, 'Icon' => '', ), 0); if (array_key_exists('Search', $this->System->ModuleManager->Modules)) $this->System->ModuleManager->Modules['Search']->RegisterSearch('user', T('Translators'), array('Name'), '`User`', $this->System->Link('/users/?search=')); Core::Cast($this->System)->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback')); Core::Cast($this->System)->RegisterPageBarItem('Left', 'User', array($this, 'ShowOnlineList')); } function ShowOnlineList() { $Output = T('Online translators').':
'; $DbResult = $this->System->Database->query('SELECT * FROM ('. 'SELECT `User`.`Name`, `User`.`ID` FROM `UserOnline` '. 'JOIN `User` ON `User`.`ID` = `UserOnline`.`User` '. 'WHERE (`ActivityTime` >= NOW() - 300) '. 'ORDER BY `ActivityTime` DESC ) AS `T` GROUP BY `Name`'); while ($DbUser = $DbResult->fetch_assoc()) { $Name = ''.$DbUser['Name'].''; $Output .= $Name.'
'; } return $Output; } function TopBarCallback() { $Output = ''; $User = ModuleUser::Cast($this->System->GetModule('User'))->User; if ($User->Licence(LICENCE_USER)) { //$DbResult =$this->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$this->System->User->Team); //$Team = $DbResult->fetch_assoc(); //$Output .= ''Moje překlady: Dokončené Rozpracované Exporty Tým: '.$Team['name'].''; $Output .= $User->Name.' '.T('Logout').''. ' '.T('My page').''. ' '.T('Options').''. ' '.T('Translated').''. ' '.T('Unfinished').''. ' '.T('Untranslated').''; } else { $Output .= ''.T('Login').' '. ''.T('Registration').''; } return $Output; } static function Cast(Module $Module): ModuleUser { if ($Module instanceof ModuleUser) { return $Module; } throw new Exception('Expected '.ModuleUser::GetClassName().' type but got '.gettype($Module)); } }