Ignore:
Timestamp:
Apr 20, 2013, 8:51:15 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Definice třída User přesunuta do modulu User. Existuje aplikační modul System->ModuleManager->ModulesUser a samotná instance třídy System->User.
  • Upraveno: Zbylá inicializace starého modulového systému třídy Module přesunuta do startovní části aplikačních modulů.
  • Upraveno: Třída System přesunuta ze souboru Common/Global do samostatného souboru Common/System.
File:
1 moved

Legend:

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

    r521 r524  
    11<?php
     2
     3include_once(dirname(__FILE__).'/UserList.php');
    24
    35define('LOGIN_USED', 'Přihlašovací jméno již použito.');
     
    4749class User extends Module
    4850{
    49   var $Dependencies = array('Log');
    5051  var $Roles = array();
    5152  var $User = array();
    52   var $DefaultRole = 2;
    5353  var $OnlineStateTimeout = 600; // in seconds
    5454  var $PermissionCache = array();
     
    5858  var $PasswordHash;
    5959 
    60   function __construct()
    61   {
     60  function __construct($System)
     61  {
     62    parent::__construct($System);
    6263    $this->PasswordHash = new PasswordHash();
    6364  }
     
    9798    {
    9899      $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']);
    99       if($DbRow['User'] != null) $this->System->Modules['Log']->NewRecord('User', 'Logout');
     100      if($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');
    100101    }
    101102    //$this->LoadPermission($this->User['Role']);
     
    107108  function Register($Login, $Password, $Password2, $Email, $Name, $PhoneNumber, $ICQ)
    108109  {
    109     global $Options, $Config;
     110    global $Config;
    110111
    111112    if(($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '')  || ($Name == '')) $Result = DATA_MISSING;
     
    155156           
    156157            $Result = USER_REGISTRATED;
    157             $this->System->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
     158            $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
    158159          }
    159160        }
     
    174175        $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0));
    175176        $Output = USER_REGISTRATION_CONFIRMED;
    176         $this->System->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.
     177        $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.
    177178          $Row['Login'].', Id='.$Row['Id']);
    178179      } else $Output = PASSWORDS_UNMATCHED;
     
    198199        $Result = USER_LOGGED_IN;
    199200        $this->Check();
    200         $this->System->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));
     201        $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));
    201202      }
    202203    } else $Result = USER_NOT_REGISTRED;
     
    208209    $SID = session_id();
    209210    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => null));
    210     $this->System->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']);
     211    $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']);
    211212    $this->Check();
    212213    return(USER_LOGGED_OUT);
     
    354355     
    355356      $Output = USER_PASSWORD_RECOVERY_SUCCESS;
    356       $this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
     357      $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
    357358    } else $Output = USER_PASSWORD_RECOVERY_FAIL;
    358359    return($Output);
     
    373374          'Salt' => $Salt, 'Locked' => 0));
    374375        $Output = USER_PASSWORD_RECOVERY_CONFIRMED;
    375         $this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);
     376        $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);
    376377      } else $Output = PASSWORDS_UNMATCHED;
    377378    } else $Output = USER_NOT_FOUND;
     
    380381}
    381382
     383class ModuleUser extends AppModule
     384{
     385  function __construct($System)
     386  {
     387    parent::__construct($System);
     388    $this->Name = 'User';
     389    $this->Version = '1.0';
     390    $this->Creator = 'Chronos';
     391    $this->License = 'GNU/GPLv3';
     392    $this->Description = 'User management';
     393    $this->Dependencies = array();
     394  } 
     395
     396  function Install()
     397  {
     398  }
     399 
     400  function Uninstall()
     401  {     
     402  }
     403 
     404  function Start()
     405  {
     406    parent::Start();
     407    $this->System->User = new User($this->System);
     408    if(isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();
     409    $this->System->RegisterPage('userlist', 'PageUserList');
     410  } 
     411 
     412  function Stop()
     413  {
     414  }
     415}
     416
    382417?>
Note: See TracChangeset for help on using the changeset viewer.