Changeset 524


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.
Location:
trunk
Files:
1 deleted
31 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Common/AppModule.php

    r469 r524  
    2424    $this->System = &$System;
    2525    $this->Database = &$System->Database;
     26    $this->Installed = false;
    2627  }
    2728 
     
    8687    unset($this->Modules[array_search($Module, $this->Modules)]); 
    8788  }
     89 
     90  /* @return Module */
     91  function SearchModuleById($Id)
     92  {
     93    foreach($this->Modules as $Module)
     94    {
     95      //DebugLog($Module->Name.' '.$Module->Id);
     96      if($Module->Id == $Id) return($Module->Name);
     97    }
     98    return('');
     99  }
     100 
    88101}
    89102
  • trunk/Common/Database.php

    r503 r524  
    7171      $this->Error = $this->Error[2];
    7272      if(($this->Error != '') and ($this->ShowSQLError == true))
    73         //echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
     73        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
    7474        throw new Exception('SQL Error: </strong>'.$this->Error.', Query: '.$Query);
    7575    }
  • trunk/Common/Global.php

    r522 r524  
    1515include_once(dirname(__FILE__).'/Database.php');
    1616include_once(dirname(__FILE__).'/Code.php');
     17include_once(dirname(__FILE__).'/System.php');
    1718include_once(dirname(__FILE__).'/Mail.php');
    18 include_once(dirname(__FILE__).'/Log.php');
    19 include_once(dirname(__FILE__).'/User.php');
    2019include_once(dirname(__FILE__).'/Page.php');
    2120include_once(dirname(__FILE__).'/Form/Form.php');
     
    2322 
    2423// Application modules
     24include_once(dirname(__FILE__).'/../Modules/System/System.php');
    2525include_once(dirname(__FILE__).'/../Modules/Error/Error.php');
     26include_once(dirname(__FILE__).'/../Modules/Log/Log.php');
    2627include_once(dirname(__FILE__).'/../Modules/File/File.php');
    2728include_once(dirname(__FILE__).'/../Modules/Meteostation/Meteostation.php');
     
    4546include_once(dirname(__FILE__).'/../Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php');
    4647
    47 class System extends Module
    48 {
    49   var $Modules;
    50   /** @var Type */
    51   var $Type;
    52   var $Pages;
    53   /** @var AppModuleManager */
    54   var $ModuleManager;
    55   var $PathItems;
    56   var $RootURLFolder;
    57 
    58   function __construct()
    59   {
    60     parent::__construct();
    61     $this->Modules = array();
    62     $this->Pages = array();
    63     $this->ModuleManager = new AppModuleManager();
    64     $this->Database = new Database();
    65     $this->FormManager = new FormManager($this->Database);
    66   } 
    67  
    68   function RegisterPage($Path, $Handler)
    69   {
    70     if(is_array($Path))
    71     {
    72       $Page = &$this->Pages;
    73       $LastKey = array_pop($Path);
    74       foreach($Path as $PathItem)
    75       {
    76         $Page = &$Page[$PathItem];       
    77       }
    78       if(!is_array($Page)) $Page = array('' => $Page);
    79       $Page[$LastKey] = $Handler;
    80     } else $this->Pages[$Path] = $Handler;
    81   }
    82  
    83   function SearchPage($PathItems, $Pages)
    84   {
    85     if(count($PathItems) > 0) $PathItem = $PathItems[0];
    86       else $PathItem = '';
    87     if(array_key_exists($PathItem, $Pages))
    88     {
    89       if(is_array($Pages[$PathItem]))
    90       {
    91         array_shift($PathItems);
    92         return($this->SearchPage($PathItems, $Pages[$PathItem]));
    93       } else return($Pages[$PathItem]);
    94     } else return('');
    95   }
    96  
    97   function PageNotFound()
    98   {
    99     return('Page '.implode('/', $this->PathItems).' not found.');
    100   }
    101  
    102   function ShowPage()
    103   {
    104     /* @var $Page Page */
    105     $ClassName = $this->SearchPage($this->PathItems, $this->Pages);     
    106     if($ClassName != '')
    107     {
    108       $Page = new $ClassName();
    109       $Page->System = &$this;
    110       $Page->Database = &$this->Database;
    111       $Page->GetOutput();
    112     } else echo($this->PageNotFound());
    113   }
    114  
    115   function ModulePresent($Name)
    116   {
    117     return(array_key_exists($Name, $this->Modules));
    118   }
    119 
    120   function AddModule($Module)
    121   {
    122     //echo('Přidávám modul '.get_class($Module).'<br />');
    123     $Module->System = &$this;
    124     $Module->Database = &$this->Database;
    125     $this->Modules[get_class($Module)] = $Module;
    126   }
    127  
    128   function AddEmailToQueue($To, $Subject, $Content, $From, $AttachmentFileId = '')
    129   {
    130     $Values = array('To' => $To,
    131       'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()',
    132       'From' => $From);
    133     if($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId;
    134     $this->Database->insert('EmailQueue', $Values);
    135   }
    136  
    137   function ProcessEmailQueue()
    138   {
    139     $Output = '';
    140     $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0');
    141     while($DbRow = $DbResult->fetch_assoc())
    142     {     
    143       $Mail = new Mail();
    144       $Mail->AddToCombined($DbRow['To']);
    145       $Mail->Subject = $DbRow['Subject'];
    146       $Mail->From = $DbRow['From'];
    147       $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain');
    148       $Mail->AddBody($DbRow['Content'], 'text/html');
    149       if($DbRow['AttachmentFile'] != '')
    150       {
    151         $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']);
    152         while($File = $DbResult2->fetch_assoc())
    153           $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']);
    154       }
    155       $Mail->Send();
    156       $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1));
    157       $this->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']);
    158       $Output .= 'To: '.$DbRow['To'].'  Subject: '.$DbRow['Subject'].'<br />';
    159     }   
    160     return($Output);
    161   }
    162  
    163   function HumanDate($Time)
    164   {
    165     return(date('j.n.Y', $Time));
    166   }
    167  
    168   function Link($Target)
    169   {
    170     return($this->RootURLFolder.$Target);
    171   }   
    172 }
    173 
    17448function GlobalInit()
    17549{
     
    20478  if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.');
    20579 
    206   // Init old modules
    207   $System->AddModule(new Log());
    208   $System->AddModule(new User());
    209   if(isset($_SERVER['REMOTE_ADDR'])) $System->Modules['User']->Check();
    210   $System->AddModule(new Bill());
    211   $System->AddModule(new Finance());
    212   $System->Modules['Finance']->MainSubject = $Config['Finance']['MainSubjectId'];
    213   $System->Modules['Finance']->DirectoryId = $Config['Finance']['DirectoryId'];
    214   $System->Modules['Finance']->LoadMonthParameters(0);
    215   $System->Modules['Log']->Database->LastQuery = 'ssd';
    216   RegisterFormClasses($System->FormManager);
    217  
     80  $Database = $System->Database;
     81  RegisterFormClasses($System->FormManager); 
    21882 
    21983  // Register new modules
    22084  $System->ModuleManager->RegisterModule(new ModuleError($System));
     85  $System->ModuleManager->RegisterModule(new ModuleSystem($System));
     86  $System->ModuleManager->RegisterModule(new ModuleLog($System));
    22187  $System->ModuleManager->RegisterModule(new ModuleFile($System));
    22288  $System->ModuleManager->RegisterModule(new ModuleMeteostation($System));
     
    236102  $System->ModuleManager->RegisterModule(new ModuleMeals($System));
    237103  $System->ModuleManager->RegisterModule(new ModuleNetworkTopology($System));
     104  $System->ModuleManager->RegisterModule(new ModuleNetworkConfig($System));
     105  $System->ModuleManager->RegisterModule(new ModuleNetworkConfigRouterOS($System));
     106  $System->ModuleManager->RegisterModule(new ModuleNetworkConfigLinux($System));
    238107  $System->ModuleManager->StartAll();
    239108}
  • trunk/Common/Module.php

    r438 r524  
    1111  var $CurrentPath = '/';
    1212
    13   function __construct()
     13  function __construct($System)
    1414  {
     15    $this->System = &$System;
     16    $this->Database = &$System->Database;   
    1517  }
    1618}
  • trunk/Common/Page.php

    r521 r524  
    6767    if($this->System->Config['Web']['UserSupport'] == 1)
    6868    {
    69       if($this->System->Modules['User']->User['Id'] == null)
     69      if($this->System->User->User['Id'] == null)
    7070        $Output .= '<a href="'.$this->System->Link('/?Action=LoginForm').'">Přihlášení</a> <a href="'.$this->System->Link('/?Action=UserRegister').'">Registrace</a>';
    71         else $Output .= $this->System->Modules['User']->User['Name'].' <a href="'.$this->System->Link('/?Action=Logout').'">Odhlásit</a>';
     71        else $Output .= $this->System->User->User['Name'].' <a href="'.$this->System->Link('/?Action=Logout').'">Odhlásit</a>';
    7272   } else $Output .= '&nbsp;';
    7373// <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>';
     
    7878  function ShowFooter()
    7979  {
    80   global $ScriptTimeStart;
     80    global $ScriptTimeStart;
    8181    $Time = round(GetMicrotime() - $ScriptTimeStart, 2);
    8282    $Output = '<div id="Footer">
    8383   <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' |';
    8484    if($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |';
    85   $Output .= '</i></div></body></html>';
     85    $Output .= '</i></div></body></html>';
    8686    return($Output);
    8787  }
  • trunk/Common/Version.php

    r522 r524  
    11<?php
    22
    3 $Revision = 522; // Subversion revision
     3$Revision = 524; // Subversion revision
    44$DatabaseRevision = 517; // SQL structure revision
    5 $ReleaseTime = '2013-04-15';
     5$ReleaseTime = '2013-04-20';
    66
    77?>
  • trunk/Modules/Chat/Chat.php

    r519 r524  
    2121    global $MonthNames;
    2222   
    23     if(!$this->System->Modules['User']->CheckPermission('Chat', 'Display')) return('Nemáte oprávnění');
     23    if(!$this->System->User->CheckPermission('Chat', 'Display')) return('Nemáte oprávnění');
    2424
    2525    if(array_key_exists('date', $_GET)) $Date = $_GET['date'];
  • trunk/Modules/File/File.php

    r514 r524  
    77  var $FilesDir;
    88 
    9   function __construct($Database)
     9  function __construct($System)
    1010  {
    11     $this->Database = $Database;
     11    parent::__construct($System);
    1212    $this->FilesDir = '';
    1313  }
     
    118118    parent::Start();
    119119    $this->System->RegisterPage('file', 'PageFile');
    120     $File = new File($this->System->Database);
    121     $File->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder'];   
    122     $this->System->AddModule($File);
     120    $this->System->AddModule(new File($this->System));
     121    $this->System->Modules['File']->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder'];
    123122  } 
    124123 
  • trunk/Modules/Finance/Customers.php

    r521 r524  
    1111    $Finance = $this->System->Modules['Finance'];
    1212    $this->System->Modules['Finance']->LoadTariffs();
    13     if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
     13    if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    1414
    1515    $Output = 'Seznam účastníků:<br/>';
  • trunk/Modules/Finance/Finance.php

    r521 r524  
    3737  function Start()
    3838  {
     39    global $Config;
     40   
    3941    parent::Start();
    4042    $this->System->RegisterPage('finance', 'PageFinance');
     
    4850    $this->System->RegisterPage(array('finance', 'import'), 'PageFinanceImportPayment');   
    4951    $this->System->RegisterPage(array('finance', 'zivnost'), 'PageFinanceTaxFiling');   
     52
     53    $this->System->AddModule(new Bill($this->System));
     54    $this->System->AddModule(new Finance($this->System));
     55    $this->System->Modules['Finance']->MainSubject = $Config['Finance']['MainSubjectId'];
     56    $this->System->Modules['Finance']->DirectoryId = $Config['Finance']['DirectoryId'];
     57    $this->System->Modules['Finance']->LoadMonthParameters(0); 
    5058  } 
    5159 
  • trunk/Modules/Finance/Import.php

    r523 r524  
    99  function Show()
    1010  {
    11     if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
     11    if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    1212    if(array_key_exists('Operation', $_GET))
    1313    {
  • trunk/Modules/Finance/Manage.php

    r521 r524  
    99  function Show()
    1010  {
    11     if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage'))
     11    if(!$this->System->User->CheckPermission('Finance', 'Manage'))
    1212      return('Nemáte oprávnění');
    1313
     
    203203    $Form->SaveValuesToDatabase(0);
    204204    $Output = $this->SystemMessage('Finance', 'Zařízení vloženo.');
    205     $this->System->Modules['Log']->NewRecord('Finance', 'NewDeviceInserted');
     205    $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewDeviceInserted');
    206206    return($Output);
    207207  }
     
    223223    $Form->SaveValuesToDatabase(0);
    224224    $Output = $this->SystemMessage('Finance', 'Záznam historie zařízení vložen.');
    225     $this->System->Modules['Log']->NewRecord('Finance', 'NewDeviceHistoryInserted');
     225    $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewDeviceHistoryInserted');
    226226    return($Output);
    227227  }
     
    246246    $DbRow = $DbResult->fetch_assoc();
    247247    $Output = $this->SystemMessage('Finance', 'Platba vložena '.$DbRow['BillCode'].'.');
    248     $this->System->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
     248    $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
    249249    return($Output);
    250250  }
     
    272272    $DbRow = $DbResult->fetch_assoc();
    273273    $Output = $this->SystemMessage('Finance', 'Faktura vložena '.$DbRow['BillCode'].'.');
    274     $this->System->Modules['Log']->NewRecord('Finance', 'NewInvoiceInserted');
     274    $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewInvoiceInserted');
    275275    return($Output);
    276276  }
     
    308308  function ShowMonthlyPayment()
    309309  {
    310     if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     310    if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
    311311    $SQL = 'SELECT Member.*, MemberPayment.MonthlyTotal AS Monthly, '.
    312312      'MemberPayment.Cash AS Cash, '.
     
    450450  function ProcessMonthlyPayment()
    451451  {
    452     if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     452    if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
    453453    $Output = '';
    454454
  • trunk/Modules/Finance/Overview.php

    r521 r524  
    1515    $Output .= '<a href="'.$this->System->Link('/finance/sluzby/').'">Přehled nabízených služeb</a><br />';
    1616    $Output .= '<a href="'.$this->System->Link('/finance/zarizeni/').'">Výpis zařízení</a><br />';
    17     if($this->System->Modules['User']->CheckPermission('Finance', 'SubjectList'))
     17    if($this->System->User->CheckPermission('Finance', 'SubjectList'))
    1818      $Output .= '<a href="'.$this->System->Link('/finance/zakaznici/').'">Seznam zákazníků</a><br />';
    1919    $Output .= '<a href="'.$this->System->Link('/finance/spotreba/').'">Spotřeba energie</a><br />';
  • trunk/Modules/Finance/UserState.php

    r521 r524  
    1414    if(array_key_exists('Subject', $_GET))
    1515    {
    16       if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     16      if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
    1717      $DbResult = $this->Database->query('SELECT * FROM Subject WHERE Id='.$_GET['Subject']);
    1818      $Subject = $DbResult->fetch_assoc();
    1919    } else
    2020    {
    21       if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
    22       $UserId = $this->System->Modules['User']->User['Id'];
     21      if(!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
     22      $UserId = $this->System->User->User['Id'];
    2323      $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$UserId.' LIMIT 1');
    2424      if($DbResult->num_rows > 0)
  • trunk/Modules/Finance/Zivnost.php

    r521 r524  
    5555  function Show()
    5656  {
    57     if(!$this->System->Modules['User']->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění');
     57    if(!$this->System->User->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění');
    5858    $this->System->Modules['Finance']->LoadTariffs(1);
    5959    //TransformFinance();
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r523 r524  
    2929  function Show()
    3030  {   
    31     if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
     31    if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    3232     
    3333    $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$_GET['id']);
     
    5656  {
    5757    $Output = '';
    58     if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
     58    if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    5959    if(array_key_exists('Operation', $_GET))
    6060    {
  • trunk/Modules/IS/IS.php

    r519 r524  
    1212  function Show()
    1313  {
    14     if(!$this->System->Modules['User']->CheckPermission('IS', 'Manage'))
     14    if(!$this->System->User->CheckPermission('IS', 'Manage'))
    1515      return('Nemáte oprávnění');
    1616
     
    107107        $_SESSION['Id'] = $Id;
    108108        //$this->Database->update($Table, 'Id='.$Id,
    109         //  array('UserCreate' => $this->System->Modules['User']->User['Id'],
     109        //  array('UserCreate' => $this->System->User->User['Id'],
    110110        //  'TimeCreate' => 'NOW()'));
    111111        $Output .= $this->ShowView($Table, $Id);   
  • trunk/Modules/Log/Log.php

    r523 r524  
    3737  {
    3838    if(array_key_exists('User', $this->System->Modules) and
    39       array_key_exists('Id', $this->System->Modules['User']->User))
    40       $UserId = $this->System->Modules['User']->User['Id'];
     39      array_key_exists('Id', $this->System->User->User))
     40      $UserId = $this->System->User->User['Id'];
    4141      else $UserId = NULL;
    4242    $this->Database->insert('Log', array('Time' => 'NOW()',
  • trunk/Modules/Network/Administration.php

    r519 r524  
    1313  function Show()
    1414  {
    15     if(!$this->System->Modules['User']->CheckPermission('Network', 'Administration')) return('Nemáte oprávnění');
     15    if(!$this->System->User->CheckPermission('Network', 'Administration')) return('Nemáte oprávnění');
    1616    $Output = '';
    1717    if(array_key_exists('Action', $_GET))
  • trunk/Modules/Network/UserHosts.php

    r519 r524  
    1717    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
    1818    $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>';
    19     $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->Modules['User']->User['Id'].') ORDER BY NetworkDevice.Name');
     19    $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->User->User['Id'].') ORDER BY NetworkDevice.Name');
    2020    while($Device = $DbResult->fetch_assoc())
    2121    {
  • trunk/Modules/NetworkShare/SharePage.php

    r523 r524  
    6868  function Show()
    6969  {
    70     if(!$this->System->Modules['User']->CheckPermission('Share', 'Display')) return('Nemáte oprávnění');
     70    if(!$this->System->User->CheckPermission('Share', 'Display')) return('Nemáte oprávnění');
    7171
    7272    // If not only online checkbox checked
  • trunk/Modules/News/News.php

    r506 r524  
    5151    $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption'];     
    5252    $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>';
    53     if($this->System->Modules['User']->CheckPermission('News', 'Insert', 'Group', $Category))
     53    if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))
    5454      $Output .= ' <a href="aktuality/?action=add&amp;category='.$Category.'">Přidat</a>';
    5555    $Output .= '</div></div><div class="Content">';
  • trunk/Modules/News/NewsPage.php

    r523 r524  
    3838    {
    3939      case 'view':
    40         if(!$this->System->Modules['User']->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
     40        if(!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
    4141        else
    4242        {
     
    4949              else $Author = $Row['Name'];
    5050            $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')';
    51             if($this->System->Modules['User']->User['Id'] == $Row['User'])
     51            if($this->System->User->User['Id'] == $Row['User'])
    5252            {
    5353              $Output .= '<div class="Action">';
     
    7979        while($DbRow = $DbResult->fetch_array())
    8080        {
    81           if($this->System->Modules['User']->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
     81          if($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
    8282          {
    8383            if($DbRow['Id'] == $Category) $Selected = ' selected="1"'; else $Selected = '';
     
    9898      case 'add2':
    9999        $RemoteAddr = GetRemoteAddress(); 
    100         if($this->System->Modules['User']->CheckPermission('News', 'Insert', 'Group', $Category))
     100        if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))
    101101        {
    102102          // Process uploaded file
     
    121121          $this->Database->insert('News', array('Category' => $Category, 'Title' => $_POST['title'],
    122122            'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr,
    123             'Enclosure' => $Enclosures, 'Author' => $this->System->Modules['User']->User['Name'], 'User' => $this->System->Modules['User']->User['Id'], 'Link' => $_POST['link']));
     123            'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'], 'User' => $this->System->User->User['Id'], 'Link' => $_POST['link']));
    124124          $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />';
    125125          $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>';
     
    130130        $DbResult = $this->Database->query('SELECT * FROM News WHERE Id='.$_GET['id']);
    131131        $Row = $DbResult->fetch_array();
    132         if($this->System->Modules['User']->User['Id'] == $Row['User'])
     132        if($this->System->User->User['Id'] == $Row['User'])
    133133        {
    134134          $Row['Content'] = str_replace('<br />', '', $Row['Content']);
     
    151151        {
    152152          $Row = $DbResult->fetch_array();
    153           if($this->System->Modules['User']->User['Id'] == $Row['User'])
     153          if($this->System->User->User['Id'] == $Row['User'])
    154154          {
    155155            $_POST['content'] = str_replace("\n", '<br />', $_POST['content']);
  • trunk/Modules/OpeningHours/OpeningHours.php

    r507 r524  
    3535  function EditSubject($Id)
    3636  {
    37     if($this->System->Modules['User']->CheckPermission('SubjectOpenTime', 'Edit'))
     37    if($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
    3838    {
    3939      $Output = '<div class="Centred">';
     
    7777   
    7878    $Output = '';
    79     if($this->System->Modules['User']->CheckPermission('SubjectOpenTime', 'Edit'))
     79    if($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
    8080    {
    8181      $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id);
     
    189189      if($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> ';
    190190     
    191       if($this->System->Modules['User']->CheckPermission('SubjectOpenTime', 'Edit'))
     191      if($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
    192192        $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />';
    193193      $Output .= '<br />';
  • trunk/Modules/Portal/Portal.php

    r523 r524  
    1616      if($HyperLink['IconFile'] == '') $HyperLink['IconFile'] = 'clear.png';
    1717        if(substr($HyperLink['URL'], 0, 4) != 'http') $HyperLink['URL'] = $this->System->Config['Web']['RootFolder'].$HyperLink['URL'];
    18         if(($HyperLink['PermissionModule'] == '') or (($HyperLink['PermissionModule'] != '') and $this->System->Modules['User']->Modules['User']->CheckPermission($HyperLink['PermissionModule'], $HyperLink['PermissionOperation'])))       
     18        if(($HyperLink['PermissionModule'] == '') or (($HyperLink['PermissionModule'] != '') and $this->System->User->User->CheckPermission($HyperLink['PermissionModule'], $HyperLink['PermissionOperation'])))       
    1919        $Output .= '<img alt="'.$HyperLink['Name'].'" src="images/favicons/'.$HyperLink['IconFile'].'" width="16" height="16" /> <a href="'.$HyperLink['URL'].'">'.$HyperLink['Name'].'</a><br />';
    2020    }
     
    5555    //$Output .= 'Server běží: '.$this->GetServerUptime().' &nbsp;  &nbsp; ';
    5656
    57     if($this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState'))
    58     {
    59       $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.$this->System->Modules['User']->User['Id'].')');
     57    if($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
     58    {
     59      $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.$this->System->User->User['Id'].')');
    6060      if($DbResult->num_rows > 0)
    6161      {
     
    7272  {
    7373    $Output = '<a href="'.$this->System->Link('/?Action=UserOptions').'">Profil</a><br />';
    74     if($this->System->Modules['User']->CheckPermission('Finance', 'MemberOptions'))
     74    if($this->System->User->CheckPermission('Finance', 'MemberOptions'))
    7575      $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Domácnost</a><br />';
    76     if($this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState'))
     76    if($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
    7777      $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />';
    78     if($this->System->Modules['User']->CheckPermission('Network', 'RegistredHostList'))
     78    if($this->System->User->CheckPermission('Network', 'RegistredHostList'))
    7979      $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />';
    80     if($this->System->Modules['User']->CheckPermission('News', 'Insert'))
     80    if($this->System->User->CheckPermission('News', 'Insert'))
    8181      $Output .= '<a href="'.$this->System->Link('/aktuality/?action=add').'">Vložení aktuality</a><br />';
    82     if($this->System->Modules['User']->CheckPermission('EatingPlace', 'Edit'))
     82    if($this->System->User->CheckPermission('EatingPlace', 'Edit'))
    8383      $Output .= '<a href="'.$this->System->Link('/jidelna/menuedit.php').'">Úprava jídelníčků</a><br />';
    84     if($this->System->Modules['User']->CheckPermission('Finance', 'Manage'))
     84    if($this->System->User->CheckPermission('Finance', 'Manage'))
    8585      $Output .= '<a href="'.$this->System->Link('/finance/sprava/').'">Správa financí</a><br />';
    86     if($this->System->Modules['User']->CheckPermission('Network', 'Administration'))
     86    if($this->System->User->CheckPermission('Network', 'Administration'))
    8787      $Output .= '<a href="'.$this->System->Link('/network/administration/').'">Správa sítě</a><br />';
    88     if($this->System->Modules['User']->CheckPermission('IS', 'Manage'))
     88    if($this->System->User->CheckPermission('IS', 'Manage'))
    8989      $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />';
    9090    return($Output);
     
    156156        $Form->SetClass('UserLogin');
    157157        $Form->OnSubmit = '?Action=Login';
    158         $Result = $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']);
     158        $Result = $this->System->User->Login($_POST['Username'], $_POST['Password']);
    159159        $Output .= $this->SystemMessage('Přihlášení', $Result);
    160160        if($Result <> USER_LOGGED_IN)
     
    170170      if($_GET['Action'] == 'Logout')
    171171      {
    172         if($this->System->Modules['User']->User['Id'] != null)
    173         {
    174           $Output .= $this->SystemMessage('Odhlášení', $this->System->Modules['User']->Logout());
     172        if($this->System->User->User['Id'] != null)
     173        {
     174          $Output .= $this->SystemMessage('Odhlášení', $this->System->User->Logout());
    175175        } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen');
    176176      } else
    177177      if($_GET['Action'] == 'UserOptions')
    178178      {
    179         if($this->System->Modules['User']->User['Id'] != null)
     179        if($this->System->User->User['Id'] != null)
    180180        {
    181181          $UserOptions = new Form($this->System->FormManager);
    182182          $UserOptions->SetClass('UserOptions');
    183           $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
     183          $UserOptions->LoadValuesFromDatabase($this->System->User->User['Id']);
    184184          $UserOptions->OnSubmit = '?Action=UserOptionsSave';
    185185          $Output .= $UserOptions->ShowEditForm();
     
    191191        $UserOptions->SetClass('UserOptions');
    192192        $UserOptions->LoadValuesFromForm();
    193         $UserOptions->SaveValuesToDatabase($this->System->Modules['User']->User['Id']);
     193        $UserOptions->SaveValuesToDatabase($this->System->User->User['Id']);
    194194        $Output .= $this->SystemMessage('Nastavení', 'Nastavení uloženo.');
    195195        $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $UserOptions->Values['Name']);
    196         $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
     196        $UserOptions->LoadValuesFromDatabase($this->System->User->User['Id']);
    197197        $UserOptions->OnSubmit = '?Action=UserOptionsSave';
    198198        $Output .= $UserOptions->ShowEditForm();
     
    209209      {
    210210        $Output .= $this->SystemMessage('Potvrzení registrace',
    211           $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));
     211          $this->System->User->RegisterConfirm($_GET['User'], $_GET['H']));
    212212      } else
    213213      if($_GET['Action'] == 'PasswordRecovery')
     
    223223        $Form->SetClass('PasswordRecovery');
    224224        $Form->LoadValuesFromForm();
    225         $Result = $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     225        $Result = $this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
    226226        $Output .= $this->SystemMessage('Obnova hesla', $Result);
    227227        if($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
     
    232232      if($_GET['Action'] == 'PasswordRecoveryConfirm')
    233233      {
    234         $Output .= $this->SystemMessage('Obnova hesla', $this->System->Modules['User']->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
     234        $Output .= $this->SystemMessage('Obnova hesla', $this->System->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
    235235      } else
    236236      if($_GET['Action'] == 'UserRegisterSave')
     
    239239        $Form->SetClass('UserRegister');
    240240        $Form->LoadValuesFromForm();
    241         $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'], $Form->Values['PhoneNumber'], $Form->Values['ICQ']);
     241        $Result = $this->System->User->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'], $Form->Values['PhoneNumber'], $Form->Values['ICQ']);
    242242        $Output .= $this->SystemMessage('Registrace nového účtu', $Result);
    243243        if($Result <> USER_REGISTRATED)
     
    251251        $Form = new Form($this->System->FormManager);
    252252        $Form->SetClass('MemberOptions');
    253         $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->Modules['User']->User['Id']);
     253        $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->User->User['Id']);
    254254        if($DbResult->num_rows > 0)
    255255        {
     
    278278          $Form->Values['BillingPeriodNext'] = 2;
    279279         
    280         $DbResult = $this->Database->update('Member', 'Id='.$this->System->Modules['User']->User['Member'],
     280        $DbResult = $this->Database->update('Member', 'Id='.$this->System->User->User['Member'],
    281281           array('FamilyMemberCount' => $Form->Values['FamilyMemberCount'],
    282282           'BillingPeriodNext' => $Form->Values['BillingPeriodNext']));
    283         $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->Modules['User']->User['Member']);
     283        $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->User->User['Member']);
    284284        $Member = $DbResult->fetch_assoc();
    285285        $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'],
     
    294294          'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '.
    295295          'Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '.
    296           'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);
     296          'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->User->User['Member']);
    297297        $DbRow = $DbResult->fetch_array();
    298298        foreach($Form->Definition['Items'] as $Index => $Item)
     
    326326        else if($Panel['Module'] == 'UserOptions')
    327327        {
    328           if($this->System->Modules['User']->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
     328          if($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
    329329        } else
    330330        if($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());
  • trunk/Modules/TV/tkr.php

    r438 r524  
    2323}
    2424
    25 $System->AddModule(new CableTVChennelListPage());
     25$System->AddModule(new CableTVChennelListPage($System));
    2626$System->Modules['CableTVChennelListPage']->GetOutput();
    2727
  • 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?>
  • trunk/Modules/WebCam/WebCam.php

    r523 r524  
    6868    global $Config;
    6969    $Output = '';
    70     //$Output = '<a href="http://www.zdechov.net/kamery/?id=1"><img alt="Webkamera školní hřiště" width="140" height="105" src="http://www.zdechov.net/images/webcam/webcam.jpg" /></a>';
    71     //$Output .= '<a href="http://www.zdechov.net/kamery/?id=2"><img alt="Webkamera střed obce obloha" width="140" height="105" src="http://www.zdechov.net/images/webcam/webcam2.jpg" /></a>';
    72     //$Output .= '<a href="http://www.zdechov.net/kamery/?id=3"><img alt="Skiareál, motokrosová grapa" width="140" height="79" src="http://www.zdechov.net/images/webcam/webcam3.jpg" /></a>';
    73     //$Output .= '<a href="http://www.zdechov.net/kamery/?id=4"><img alt="Fotbalové hřiště" width="140" height="79" src="http://www.zdechov.net/images/webcam/webcam4.jpg" /></a>';
     70    $Output = '<a href="http://www.zdechov.net/kamery/?id=1"><img alt="Webkamera školní hřiště" width="140" height="105" src="http://www.zdechov.net/images/webcam/webcam.jpg" /></a>';
     71    $Output .= '<a href="http://www.zdechov.net/kamery/?id=2"><img alt="Webkamera střed obce obloha" width="140" height="105" src="http://www.zdechov.net/images/webcam/webcam2.jpg" /></a>';
     72    $Output .= '<a href="http://www.zdechov.net/kamery/?id=3"><img alt="Skiareál, motokrosová grapa" width="140" height="79" src="http://www.zdechov.net/images/webcam/webcam3.jpg" /></a>';
     73    $Output .= '<a href="http://www.zdechov.net/kamery/?id=4"><img alt="Fotbalové hřiště" width="140" height="79" src="http://www.zdechov.net/images/webcam/webcam4.jpg" /></a>';
    7474          return($Output);   
    7575  } 
  • trunk/block/index.php

    r438 r524  
    4141}
    4242
    43 $System->AddModule(new BlockPage());
     43$System->AddModule(new BlockPage($System));
    4444$System->Modules['BlockPage']->GetOutput();
    4545
  • trunk/missing.php

    r438 r524  
    1313}
    1414
    15 $System->AddModule(new MissingPage());
     15$System->AddModule(new MissingPage($System));
    1616$System->Modules['MissingPage']->GetOutput();
    1717
  • trunk/temp/renumbering.php

    r457 r524  
    5555}
    5656
    57 $System->AddModule(new Renumbering());
     57$System->AddModule(new Renumbering($System));
    5858$System->Modules['Renumbering']->GetOutput();
    5959
  • trunk/temp/user_mail.php

    r457 r524  
    3636}
    3737
    38 $System->AddModule(new Transform());
     38$System->AddModule(new Transform($System));
    3939$System->Modules['Transform']->GetOutput();
    4040
Note: See TracChangeset for help on using the changeset viewer.