Changeset 501 for trunk/Modules/Portal


Ignore:
Timestamp:
Mar 10, 2013, 8:15:46 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: FormManager pro objektové řešení zrušení vazeb na třídu System. FormManager nyní obsluhuje existující formulářové typy a třídy formulářů.
  • Přidáno: Formulářový typ FileContent zajistí načtení obsahu souboru. Typ File pak zajistí i uložení do databáze a přiřazení Id do tabulky File.
  • Odstraněno: Adresář docs obsahoval staré dokumenty. Ty musí být přesunuty do adresáře files a registrovány do databáze.
  • Upraveno: Třídy Database nyní bude hlásit chyby přes výjimky PHP.
File:
1 edited

Legend:

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

    r494 r501  
    11<?php
    22
    3 include_once('Common/Global.php');
     3include_once(dirname(__FILE__).'/../../Common/Global.php');
    44
    55class PagePortal extends Page
     
    4545    $TotalUser = $DbRow[0];
    4646
    47     $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDeviceType.ShowOnline = 1 AND NetworkDevice.Online = 1');
     47    $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice '.
     48      'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '.
     49      'WHERE NetworkDeviceType.ShowOnline = 1 AND NetworkDevice.Online = 1');
    4850    $DbRow = $DbResult->fetch_array();
    4951    $OnlineUser = $DbRow[0];
     
    132134  function Show()
    133135  {
    134     global $Database, $Config, $User;
     136    global $Config, $User;
    135137
    136138    $Output = '';
     
    143145      if($_GET['Action'] == 'LoginForm')
    144146      {
    145         $Form = new Form('UserLogin');
     147        $Form = new Form($this->System->FormManager);
     148        $Form->SetClass('UserLogin');
    146149        $Form->OnSubmit = '?Action=Login';
    147150        $Output .= $Form->ShowEditForm();
     
    153156        if(array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST))
    154157        {
    155         $Form = new Form('UserLogin');
     158        $Form = new Form($this->System->FormManager);
     159        $Form->SetClass('UserLogin');
    156160        $Form->OnSubmit = '?Action=Login';
    157161        $Result = $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']);
     
    178182        if($this->System->Modules['User']->User['Id'] != null)
    179183        {
    180           $UserOptions = new Form('UserOptions');
     184          $UserOptions = new Form($this->System->FormManager);
     185          $UserOptions->SetClass('UserOptions');
    181186          $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
    182187          $UserOptions->OnSubmit = '?Action=UserOptionsSave';
     
    186191      if($_GET['Action'] == 'UserOptionsSave')
    187192      {
    188         $UserOptions = new Form('UserOptions', array());
     193        $UserOptions = new Form($this->System->FormManager);
     194        $UserOptions->SetClass('UserOptions');
    189195        $UserOptions->LoadValuesFromForm();
    190196        $UserOptions->SaveValuesToDatabase($this->System->Modules['User']->User['Id']);
     
    197203      if($_GET['Action'] == 'UserRegister')
    198204      {
    199         $Form = new Form('UserRegister');
     205        $Form = new Form($this->System->FormManager);
     206        $Form->SetClass('UserRegister');
    200207        //$Form->LoadValuesFromForm();
    201208        $Form->OnSubmit = '?Action=UserRegisterSave';
     
    209216      if($_GET['Action'] == 'PasswordRecovery')
    210217      {
    211         $Form = new Form('PasswordRecovery');
     218        $Form = new Form($this->System->FormManager);
     219        $Form->SetClass('PasswordRecovery');
    212220        $Form->OnSubmit = '?Action=PasswordRecovery2';
    213221        $Output .= $Form->ShowEditForm();
     
    215223      if($_GET['Action'] == 'PasswordRecovery2')
    216224      {
    217         $Form = new Form('PasswordRecovery');
     225        $Form = new Form($this->System->FormManager);
     226        $Form->SetClass('PasswordRecovery');
    218227        $Form->LoadValuesFromForm();
    219228        $Result = $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     
    230239      if($_GET['Action'] == 'UserRegisterSave')
    231240      {
    232         $Form = new Form('UserRegister', array());
     241        $Form = new Form($this->System->FormManager);
     242        $Form->SetClass('UserRegister');
    233243        $Form->LoadValuesFromForm();
    234244        $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']);
     
    242252      if($_GET['Action'] == 'MemberOptions')
    243253      {
    244         $UserOptions = new Form('MemberOptions');
     254        $Form = new Form($this->System->FormManager);
     255        $Form->SetClass('MemberOptions');
    245256        $DbResult = $this->Database->query('SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->Modules['User']->User['Id']);
    246257        if($DbResult->num_rows > 0)
     
    252263           'ON Subject.Id = Member.Subject WHERE Member.Id='.$CustomerUserRel['Customer']);       
    253264          $DbRow = $DbResult->fetch_array();
    254           foreach($UserOptions->Definition['Items'] as $Index => $Item)
     265          foreach($Form->Definition['Items'] as $Index => $Item)
    255266          {
    256             $UserOptions->Values[$Index] = $DbRow[$Index];
     267            $Form->Values[$Index] = $DbRow[$Index];
    257268          }
    258           $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
    259           $Output .= $UserOptions->ShowEditForm();
     269          $Form->OnSubmit = '?Action=MemberOptionsSave';
     270          $Output .= $Form->ShowEditForm();
    260271        } else $Output .= $this->SystemMessage('Chyba', 'Nejste zákazníkem');
    261272      } else
    262273      if($_GET['Action'] == 'MemberOptionsSave')
    263274      {
    264         $UserOptions = new Form('MemberOptions');
    265         $UserOptions->LoadValuesFromForm();
    266         if($UserOptions->Values['FamilyMemberCount'] < 0)
    267           $UserOptions->Values['FamilyMemberCount'] = 0;
    268         if($UserOptions->Values['BillingPeriodNext'] < 2)
    269           $UserOptions->Values['BillingPeriodNext'] = 2;
     275        $Form = new Form($this->System->FormManager);
     276        $Form->SetClass('MemberOptions');
     277        $Form->LoadValuesFromForm();
     278        if($Form->Values['FamilyMemberCount'] < 0)
     279          $Form->Values['FamilyMemberCount'] = 0;
     280        if($Form->Values['BillingPeriodNext'] < 2)
     281          $Form->Values['BillingPeriodNext'] = 2;
    270282         
    271283        $DbResult = $this->Database->update('Member', 'Id='.$this->System->Modules['User']->User['Member'],
    272            array('FamilyMemberCount' => $UserOptions->Values['FamilyMemberCount'],
    273            'BillingPeriodNext' => $UserOptions->Values['BillingPeriodNext']));
     284           array('FamilyMemberCount' => $Form->Values['FamilyMemberCount'],
     285           'BillingPeriodNext' => $Form->Values['BillingPeriodNext']));
    274286        $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->Modules['User']->User['Member']);
    275287        $Member = $DbResult->fetch_assoc();
    276288        $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'],
    277           array('Name' => $UserOptions->Values['Name'], 'AddressStreet' => $UserOptions->Values['AddressStreet'],
    278           'AddressTown' => $UserOptions->Values['AddressTown'], 'AddressCountry' => $UserOptions->Values['AddressCountry'],
    279           'AddressPSC' => $UserOptions->Values['AddressPSC'], 'IC' => $UserOptions->Values['IC'],
     289          array('Name' => $Form->Values['Name'], 'AddressStreet' => $Form->Values['AddressStreet'],
     290          'AddressTown' => $Form->Values['AddressTown'], 'AddressCountry' => $Form->Values['AddressCountry'],
     291          'AddressPSC' => $Form->Values['AddressPSC'], 'IC' => $Form->Values['IC'],
    280292          'DIC' => $UserOptions->Values['DIC']));
    281293        $Output .= $this->SystemMessage('Nastavení', 'Nastavení domácnosti uloženo.');
    282         $this->System->Modules['Log']->NewRecord('Member+Subject', 'Nastavení člena/subjektu změněno', $UserOptions->Values['Name']);
    283         $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);
     294        $this->System->Modules['Log']->NewRecord('Member+Subject', 'Nastavení člena/subjektu změněno',
     295          $Form->Values['Name']);
     296        $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, Member.BillingPeriodNext, '.
     297          'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '.
     298          'Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '.
     299          'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);
    284300        $DbRow = $DbResult->fetch_array();
    285         foreach($UserOptions->Definition['Items'] as $Index => $Item)
    286         {
    287           $UserOptions->Values[$Index] = $DbRow[$Index];
     301        foreach($Form->Definition['Items'] as $Index => $Item)
     302        {
     303          $Form->Values[$Index] = $DbRow[$Index];
    288304        }
    289         $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
    290         $Output .= $UserOptions->ShowEditForm();
     305        $Form->OnSubmit = '?Action=MemberOptionsSave';
     306        $Output .= $Form->ShowEditForm();
    291307      }
    292308    }
    293309
    294     $Database->select_db($Config['Database']['Database']);
    295 
    296     $DbResult = $Database->query('SELECT * FROM `HyperlinkGroup`');
     310    $this->Database->select_db($Config['Database']['Database']);
     311
     312    $DbResult = $this->Database->query('SELECT * FROM `HyperlinkGroup`');
    297313    while($DbRow = $DbResult->fetch_assoc())
    298314      $HyperlinkGroups[$DbRow['Id']] = $DbRow;
     
    302318    //$Output .= $this->InfoBar();
    303319    $Output .= '<table id="MainTable"><tr>';
    304     $DbResult = $Database->select('PanelColumn', '*');
     320    $DbResult = $this->Database->select('PanelColumn', '*');
    305321    while($PanelColumn =  $DbResult->fetch_assoc())
    306322    {
     
    308324        else $Width = '';
    309325      $Output .= '<td valign="top"'.$Width.'>';
    310       $DbResult2 = $Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`');
     326      $DbResult2 = $this->Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`');
    311327      while($Panel = $DbResult2->fetch_assoc())
    312328      {
Note: See TracChangeset for help on using the changeset viewer.