Ignore:
Timestamp:
Mar 6, 2023, 1:48:45 AM (14 months ago)
Author:
chronos
Message:
  • Fixed: Class types casting for better type checking.
  • Fixed: XML direct export.
  • Modified: User class instance moved from Core class to ModuleUser class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/User/User.php

    r892 r893  
    11<?php
    22
     3include_once(dirname(__FILE__).'/ModuleUser.php');
    34include_once(dirname(__FILE__).'/UserList.php');
    45include_once(dirname(__FILE__).'/Options.php');
    56include_once(dirname(__FILE__).'/Registration.php');
    67include_once(dirname(__FILE__).'/Profile.php');
    7 
    8 class ModuleUser extends Module
    9 {
    10   function __construct(System $System)
    11   {
    12     parent::__construct($System);
    13     $this->Name = 'User';
    14     $this->Version = '1.1';
    15     $this->Creator = 'Chronos';
    16     $this->License = 'GNU/GPL';
    17     $this->Description = 'User and permission management';
    18     $this->Dependencies = array();
    19   }
    20 
    21   function DoStart(): void
    22   {
    23     $this->System->User = new User($this->System);
    24     $this->System->RegisterPage(['users'], 'PageUserList');
    25     $this->System->RegisterPage(['options'], 'PageUserOptions');
    26     $this->System->RegisterPage(['registration'], 'PageUserRegistration');
    27     $this->System->RegisterPage(['user'], 'PageUserProfile');
    28     $this->System->RegisterPage(['login'], 'PageUserLogin');
    29     Core::Cast($this->System)->RegisterMenuItem(array(
    30       'Title' => T('Translators'),
    31       'Hint' => 'Seznam registrovaných uživatelů',
    32       'Link' => $this->System->Link('/users/'),
    33       'Permission' => LICENCE_ANONYMOUS,
    34       'Icon' => '',
    35     ), 0);
    36     if (array_key_exists('Search', $this->System->ModuleManager->Modules))
    37       $this->System->ModuleManager->Modules['Search']->RegisterSearch('user',
    38       T('Translators'), array('Name'), '`User`', $this->System->Link('/users/?search='));
    39       Core::Cast($this->System)->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
    40       Core::Cast($this->System)->RegisterPageBarItem('Left', 'User', array($this, 'ShowOnlineList'));
    41   }
    42 
    43   function ShowOnlineList()
    44   {
    45     $Output = T('Online translators').':<br />';
    46     $DbResult = $this->System->Database->query('SELECT * FROM ('.
    47       'SELECT `User`.`Name`, `User`.`ID` FROM `UserOnline` '.
    48       'JOIN `User` ON `User`.`ID` = `UserOnline`.`User` '.
    49       'WHERE (`ActivityTime` >= NOW() - 300) '.
    50       'ORDER BY `ActivityTime` DESC ) AS `T` GROUP BY `Name`');
    51     while ($DbUser = $DbResult->fetch_assoc())
    52     {
    53       $Name = '<a href="'.$this->System->Link('/user/?user='.$DbUser['ID']).'">'.$DbUser['Name'].'</a>';
    54       $Output .= $Name.'<br />';
    55     }
    56     return $Output;
    57   }
    58 
    59   function TopBarCallback()
    60   {
    61     $Output = '';
    62     if ($this->System->User->Licence(LICENCE_USER))
    63     {
    64       //$DbResult =$this->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$this->System->User->Team);
    65       //$Team = $DbResult->fetch_assoc();
    66       //$Output .= ''<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>';
    67       $Output .= $this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'.
    68           ' <a href="'.$this->System->Link('/user/?user='.$this->System->User->Id).'">'.T('My page').'</a>'.
    69           ' <a href="'.$this->System->Link('/options/').'">'.T('Options').'</a>'.
    70           ' <a title="Vámi přeložené texty" href="'.$this->System->Link('/TranslationList.php?user='.
    71           $this->System->User->Id.'&amp;group=0&amp;state=2&amp;text=&amp;entry=').'">'.T('Translated').'</a>'.
    72           ' <a title="Vaše rozpracované text" href="'.$this->System->Link('/TranslationList.php?user='.
    73           $this->System->User->Id.'&amp;group=0&amp;state=3&amp;text=&amp;entry=').'">'.T('Unfinished').'</a>'.
    74           ' <a title="Nikým nepřeložené texty" href="'.
    75           $this->System->Link('/TranslationList.php?user=0&amp;group=0&amp;state=1&amp;text=&amp;entry=').'">'.T('Untranslated').'</a>';
    76     } else
    77     {
    78       $Output .= '<a href="'.$this->System->Link('/login/').'">'.T('Login').'</a>&nbsp;'.
    79         '<a href="'.$this->System->Link('/registration/').'">'.T('Registration').'</a>';
    80     }
    81     return $Output;
    82   }
    83 }
    848
    859class PageUserLogin extends Page
     
    11741{
    11842  var $Id;
    119   var $Name;
     43  public string $Name;
    12044  var $Team;
    12145  var $Role;
     
    12650  var $OnlineStateTimeout;
    12751  var $PreferredVersion = 0;
     52  public string $PreferredVersionGame;
     53  public string $Email;
     54  public string $Info;
    12855
    12956  function __construct(System $System)
Note: See TracChangeset for help on using the changeset viewer.