Changeset 9


Ignore:
Timestamp:
Oct 11, 2008, 11:06:21 PM (16 years ago)
Author:
george
Message:
  • Přidáno: Částečná podpora pro historii všech záznamů. Editace vytváří nový záznam. Zobrazení historie dané položky.
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • base.php

    r8 r9  
    2727  $Output .= '<th>Akce</th></tr>';
    2828
     29  $Where = '';
     30
    2931  if(($Column != '') and ($ColumnValue != 0))
    3032  {
    31     $Where = $Column.'='.$ColumnValue;
     33    $Where .= ' AND (t1.'.$Column.'='.$ColumnValue.')';
    3234    $ColumnSelection = '&amp;Column='.$Column.'&amp;ColumnValue='.$ColumnValue;
    3335    $FullListLink = '<a href="?Action=ViewList&amp;Table='.$List['TableName'].'">Celkový seznam</a>';
    34   } else
    35   {
    36     $Where = '1';
     36  } else
     37  {
    3738    $ColumnSelection = '';
    3839    $FullListLink = '';
     
    5253  {
    5354    $OrderDirection = array('ASC', 'DESC');
    54     $Order = 'ORDER BY `'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']];
     55    $Order = 'ORDER BY t1.`'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']];
    5556  } else $Order = '';
    5657
     
    5859  //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))';
    5960  $Where .= ' '.$Order;
    60   $DbResult = $Database->select($List['TableName'], 'COUNT(*)', $Where);
    61   //echo($Database->LastQuery);
     61  $DbResult = $Database->query('SELECT COUNT(t2.Id) AS Count FROM (SELECT DISTINCT(ItemId) as Id FROM `'.$List['TableName'].'` as t1 WHERE 1'.$Where.') as t2');
     62  //echo($Database->LastQuery.'<br>');
    6263  $DbRow = $DbResult->fetch_array();
    6364  $TotalItemCount = $DbRow[0];
    6465
    65   $DbResult = $Database->select($List['TableName'], '*', $Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);
     66  $DbResult = $Database->query('SELECT t1.* FROM `'.$List['TableName'].'` AS t1 LEFT JOIN `'.$List['TableName'].'` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE t2.ItemId IS NULL'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);
     67  //echo($Database->LastQuery.'<br>');
    6668  while($DbRow = $DbResult->fetch_array())
    6769  {
     
    8789}
    8890
     91function ShowHistory($List, $Id, $Title = '')
     92{
     93  global $Database, $Types, $Config;
     94
     95  if($Title == '') $Output = '<div>'.$List['Title'].'</div>';
     96    else $Output = '<div>'.$Title.'</div>';
     97  $Output .= '<table class="WideTable"><tr>';
     98  foreach($List['Items'] as $Item)
     99  {
     100    if($Item['VisibleInList'] == 1)
     101      $Output .= '<th><a href="?OrderColumn='.$Item['Name'].'">'.$Item['TextBefore'].'</a></th>';
     102  }
     103  $Output .= '<th>Akce</th></tr>';
     104
     105  $Where = ' AND (ItemId='.$Id.')';
     106
     107  // Handle ordering
     108  if(array_key_exists('OrderColumn', $_GET))
     109  {
     110    if($_SESSION['OrderColumn'] == $_GET['OrderColumn']) // Same column => reverse orded
     111      $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2;
     112    if($_SESSION['OrderTable'] != $List['TableName']) // Different table => set ascending order
     113      $_SESSION['OrderDirection'] = 0;
     114    $_SESSION['OrderColumn'] = $_GET['OrderColumn'];
     115    $_SESSION['OrderTable'] = $List['TableName'];
     116  }
     117  if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['TableName']))
     118  {
     119    $OrderDirection = array('ASC', 'DESC');
     120    $Order = 'ORDER BY t1.`'.$_SESSION['OrderColumn'].'` '.$OrderDirection[$_SESSION['OrderDirection']];
     121  } else $Order = '';
     122
     123  if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0;
     124  //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))';
     125  $Where .= ' '.$Order;
     126  $DbResult = $Database->query('SELECT COUNT(t2.Id) AS Count FROM (SELECT DISTINCT(ItemId) as Id FROM `'.$List['TableName'].'` as t1 WHERE 1'.$Where.') as t2');
     127  //echo($Database->LastQuery.'<br>');
     128  $DbRow = $DbResult->fetch_array();
     129  $TotalItemCount = $DbRow[0];
     130
     131  $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'` WHERE 1'.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);
     132  //echo($Database->LastQuery.'<br>');
     133  while($DbRow = $DbResult->fetch_array())
     134  {
     135    $Output .= '<tr>';
     136    foreach($List['Items'] as $Index => $Item)
     137    {
     138      if($Item['VisibleInList'] == 1)
     139      {
     140        $ItemType = explode(':', $Item['Type']);
     141        $Type = $Types[$ItemType[0]];
     142        $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     143        if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition);
     144        else $Value = $Type['CallbackView'];
     145        $Output .= '<td>'.$Value.'</td>';
     146      }
     147    }
     148    $Output .= '<td><a href="?Action=ViewItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['Id'].'">Zobrazit</a> </td></tr>';
     149  }
     150  $Output .= '</table>';
     151  $Output .= PagesList($Page, $TotalItemCount);
     152  $Output .= '<a href="?Action=AddItem&amp;Table='.$List['TableName'].$ColumnSelection.'">Přidat</a> '.$FullListLink;
     153  return($Output);
     154}
     155
    89156function ShowEditItem($List, $Id)
    90157{
    91158  global $Database, $Types;
    92159
    93   $Output = '<form action="?Action=EditItemFinish&amp;Item='.$Id.'" method="post"><table class="WideTable">';
    94   $Output .= '<tr><th>Jméno položky</th><th>Hodnota</th></tr>';
    95160  $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id);
    96161  while($DbRow = $DbResult->fetch_array())
    97162  {
     163    $DefinitionItems = array();
    98164    foreach($List['Items'] as $Index => $Item)
    99165    {
     
    101167      if($ItemType[0] != 'PointerOneToMany')
    102168      {
    103         $Type = $Types[$ItemType[0]];
    104         $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
    105         if(is_callable($Type['CallbackEdit'])) $Value = $Type['CallbackEdit']($Type, $ItemDefinition);
    106         else $Value = $Type['CallbackEdit'];
    107         if($Item['Required'] == 1) $Required = '*'; else $Required = '';
    108         $Output .= '<tr><td>'.$Item['TextBefore'].':'.$Required.'</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>';
    109       }
    110     }
    111   }
    112   $Output .= '</table><input type="submit" value="Uložit"></form>';
     169        $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     170      }
     171    }
     172  }
     173  $Form = new Form();
     174  $Form->Definition = array
     175  (
     176    'Title' => 'Titulek',
     177    'SubmitBuffonText' => 'Uložit',
     178    'Items' => $DefinitionItems,
     179  );
     180  $Form->OnSubmit = '?Action=EditItemFinish&amp;Item='.$Id;
     181  $Output .= $Form->ShowEditForm();
    113182  if(($Column != '') and ($ColumnValue != 0))
    114183  {
     
    118187    $Output .= '<a href="?Action=ShowList&amp;Table='.$List['TableName'].'">Celkový seznam</a>';
    119188  }
    120 
    121189  return($Output);
    122190}
     
    124192function ShowEditItemFinish($List, $Id)
    125193{
    126   global $Database, $Types;
     194  global $Database, $Types, $System;
    127195
    128196  $Values = array();
     
    135203    }
    136204  }
    137   $Database->update($List['TableName'], 'Id='.$Id, $Values);
     205  $DbResult = $Database->select($List['TableName'], 'ItemId', 'Id='.$Id);
     206  $DbRow = $DbResult->fetch_assoc();
     207  $Values['ItemId'] = $DbRow['ItemId'];
     208  $Values['Author'] = $System->Modules['User']->User['Id'];
     209  $Values['CreationTime'] = 'NOW()';
     210  $Values['ValidTimeFrom'] = 'NOW()';
     211  $Database->insert($List['TableName'], $Values);
    138212  //echo($Database->LastQuery);
    139213  $Output = 'Změny uloženy.';
     
    182256function ShowAddItemFinish($List)
    183257{
    184   global $Database, $Types;
     258  global $Database, $Types, $System;
    185259
    186260  $Values = array();
     
    193267    }
    194268  }
     269  $Values['Author'] = $System->Modules['User']->User['Id'];
     270  $Values['CreationTime'] = 'NOW()';
     271  $Values['ValidTimeFrom'] = 'NOW()';
     272  $DbResult = $Database->select($List['TableName'], 'MAX(ItemId)');
     273  $DbRow = $DbResult->fetch_row();
     274  $AutoincrementId = $DbRow[0];
     275  $Values['ItemId'] = $AutoincrementId + 1;
    195276  $Database->insert($List['TableName'], $Values);
    196277  //echo($Database->LastQuery);
     
    208289  while($DbRow = $DbResult->fetch_array())
    209290  {
    210     $Output = '<table class="WideTable">';
    211     $Output .= '<tr><th>Jméno položky</th><th>Hodnota</th></tr>';
     291    $DefinitionItems = array();
    212292    foreach($List['Items'] as $Index => $Item)
    213293    {
     
    215295      if($ItemType[0] != 'PointerOneToMany')
    216296      {
    217         $Type = $Types[$ItemType[0]];
    218         $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
    219         if(is_callable($Type['CallbackView'])) $Value = $Type['CallbackView']($Type, $ItemDefinition);
    220         else $Value = $Type['CallbackView'];
    221         $Output .= '<tr><td>'.$Item['TextBefore'].':</td><td title="'.$Item['Help'].'">'.$Value.'</td></tr>';
    222       }
    223     }
    224     $Output .= '</table>';
     297        $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => 0);
     298      }
     299    }
     300    $Form = new Form();
     301    $Form->Definition = array
     302    (
     303      'Title' => 'Titulek',
     304      'Items' => $DefinitionItems,
     305    );
     306    $Output .= $Form->ShowReadOnlyForm();
    225307    $Output .= '<a href="?Action=EditItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['Id'].'">Editovat</a> ';
    226308
     
    232314      $Output .= '<a href="?Action=ShowList&amp;Table='.$List['TableName'].'">Celkový seznam</a>';
    233315    }
     316    $Output .= ' <a href="?Action=ShowHistory&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'">Historie</a>';
    234317    $Output .= '<div class="line"></div>';
    235 
    236318    foreach($List['Items'] as $Index => $Item)
    237319    {
     
    306388        case 'AddItemFinish':
    307389          $Output = ShowAddItemFinish($List);
     390          break;
     391        case 'ShowHistory':
     392          $Output = ShowHistory($List, $_SESSION['Item']);
    308393          break;
    309394        case 'ShowList':
  • database.php

    r1 r9  
    1111  function query($Query)
    1212  {
    13     $this->LastQuery = $Query; 
    14     return(parent::query($Query)); 
     13    $this->LastQuery = $Query;
     14    return(parent::query($Query));
    1515  }
    1616
     
    1818  {
    1919    $this->LastQuery = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition;
    20     return($this->query($this->LastQuery)); 
     20    return($this->query($this->LastQuery));
    2121  }
    2222
     
    2424  {
    2525    $this->LastQuery = "DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition;
    26     $this->query($this->LastQuery); 
     26    $this->query($this->LastQuery);
    2727  }
    2828 
     
    4141    $Values = substr($Values, 1);
    4242    $this->LastQuery = 'INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')';
    43     $this->query($this->LastQuery); 
     43    $this->query($this->LastQuery);
    4444  }
    4545 
  • forms.php

    r8 r9  
    3333      if(!array_key_exists($Index, $this->Values) and isset($Item['Value'])) $this->Values[$Index] = $Item['Value'];
    3434      if(is_callable($Type['CallbackEdit'])) $Edit = $Type['CallbackEdit']($Type, $Item);
    35       else $Edit = $Type['CallbackEdit'];
    36 /*
    37       switch($Type[0])
    38       {
    39         case 'Boolean':
    40           if($this->Values[$Index] == 0) $Checked = ''; else $Checked = ' CHECKED';
    41           $Edit = '<input type="checkbox" name="'.$Context.$Index.'"'.$Checked.'>';
    42           break;
    43         case 'String':
    44           $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
    45           break;
    46         case 'Password':
    47           $Edit = '<input type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
    48           break;
    49         case 'Integer':
    50           $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
    51           break;
    52         case 'Float':
    53           $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
    54           break;
    55         case 'Time':
    56           if($this->Values[$Index] == 'Now') $this->Values[$Index] = date('j.n.Y');
    57           $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">';
    58           break;
    59         case 'Array':
    60           $Form  = new Form($Item['ItemClass']);
    61           $Edit = '<script type="text/javascript" id="syndication">'.
    62             "var Count = 0;".
    63             "function AddItem() {".
    64             "Count = Count + 1;".
    65             "var newcontent = document.createElement('div');".
    66             "newcontent.id = '".$Context.$Item['ItemClass']."-' + Count;".
    67             "newcontent.innerHTML = '<input type=\"hidden\" name=\"".$Context.$Item['ItemClass']."-' + Count + '\">".$Form->ShowEditBlock($Context.$Item['ItemClass']."-' + Count + '")."';".
    68             "var scr = document.getElementById('syndication');".
    69             "scr.parentNode.insertBefore(newcontent, scr); }".
    70             '</script>';
    71             $Edit .= '<form><input type="button" onclick="AddItem();" value="Přidat položku"></form>';
    72           break;
    73         default:
    74           if(array_key_exists($Item['Type'], $FormTypes))
    75           {
    76             // Custom types
    77             switch($FormTypes[$Item['Type']]['Type'])
    78             {
    79               case 'Enumeration':
    80                 $Edit = '<select name="'.$Context.$Index.'">';
    81                 foreach($FormTypes[$Item['Type']]['States'] as $StateIndex => $StateName)
    82                   $Edit .= '<option value="'.$StateIndex.'">'.$StateName.'</option>';
    83                 $Edit .= '</select>';
    84                 break;
    85               case 'Reference':
    86                 $Edit = '<select name="'.$Context.$Index.'">';
    87                 $DbResult = $Database->select($FormTypes[$Item['Type']]['Table'], $FormTypes[$Item['Type']]['Id'].' as Id, '.$FormTypes[$Item['Type']]['Name'].' as Name', $FormTypes[$Item['Type']]['Filter'].' ORDER BY Name');
    88                 while($Row = $DbResult->fetch_array())
    89                   $Edit .= '<option value="'.$Row['Id'].'">'.$Row['Name'].'</option>';
    90                 $Edit .= '</select>';
    91                 break;
    92               default:
    93                 $Edit = 'Neznámý typ';
    94             }
    95           } else $Edit = 'Neznámý typ';
    96       }
    97         */
     35      else $Edit = $Type['CallbackEdit'];
     36      array_push($Table['Rows'], array($Item['Caption'].':', $Edit));
     37    }
     38    return($Table);
     39  }
     40
     41  function ShowReadOnlyForm()
     42  {
     43    $Output = '<center><div align="center">';
     44    $Table = $this->ShowReadOnlyBlock();
     45    $Output .= $this->Definition['Title'].Table($Table).'</div></form>';
     46    return($Output);
     47  }
     48
     49  function ShowReadOnlyBlock($Context = '')
     50  {
     51    global $Database, $Types;
     52
     53    $Table = array(
     54      'Header' => array('Položka', 'Hodnota'),
     55      'Rows' => array(),
     56    );
     57    if($Context != '') $Context = $Context.'-';
     58    foreach($this->Definition['Items'] as $Item)
     59    {
     60      $ItemType = explode(':', $Item['Type']);
     61      $Index = $Item['Name'];
     62      $Type = $Types[$ItemType[0]];
     63      if(!array_key_exists($Index, $this->Values) and isset($Item['Value'])) $this->Values[$Index] = $Item['Value'];
     64      if(is_callable($Type['CallbackView'])) $Edit = $Type['CallbackView']($Type, $Item);
     65      else $Edit = $Type['CallbackView'];
    9866      array_push($Table['Rows'], array($Item['Caption'].':', $Edit));
    9967    }
  • global.php

    r8 r9  
    1515include_once('page.php');
    1616include_once('forms.php');
     17include_once('base.php');
    1718
    1819class System extends Module
     
    4344$System->AddModule(new User());
    4445$System->Modules['User']->Check();
     46LoadTypeDefinition();
     47LoadListDefinition();
    4548
    4649$MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
  • index.php

    r8 r9  
    22
    33include_once('global.php');
    4 include('base.php');
    54
    65class IndexPage extends Page
     
    3029        array('Name' => 'Password2', 'Type' => 'Password', 'Caption' => 'Potvrzení hesla', 'Value' => ''),
    3130        array('Name' => 'Email', 'Type' => 'String', 'Caption' => 'E-mail', 'Value' => ''),
    32         array('NAme' => 'FirstName', 'Type' => 'String', 'Caption' => 'Křestní jméno', 'Value' => ''),
     31        array('Name' => 'FirstName', 'Type' => 'String', 'Caption' => 'Křestní jméno', 'Value' => ''),
    3332        array('Name' => 'SecondName', 'Type' => 'String', 'Caption' => 'Příjmení', 'Value' => ''),
    3433      ),
     
    4544      {
    4645        $Output .= $this->SystemMessage('Odhlášení', $this->System->Modules['User']->Logout());
     46      } else
     47      if($_GET['Action'] == 'LoginForm')
     48      {
     49        $Form = new Form();
     50        $Form->Definition = $FormUserLogin;
     51        $Form->OnSubmit = '?Action=Login';
     52        $Output .= $Form->ShowEditForm();
    4753      } else
    4854      if($_GET['Action'] == 'UserRegister')
     
    6975      if(!array_key_exists('Action', $_GET))
    7076      {
    71         $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=LoginForm">Přihlášení</a> <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserRegister">Registrace</a>';
     77        $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=LoginForm">Přihlášení</a><br /><a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserRegister">Registrace</a>';
    7278        $Form = new Form();
    7379        $Form->Definition = $FormUserLogin;
     
    8086      $Output .= $this->System->Modules['User']->User['UserName'].' <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=Logout">Odhlásit</a>';
    8187      $Output .= '<br /><br />';
    82       LoadTypeDefinition();
    83       LoadListDefinition();
    8488      $Output .= TableList(1);
    8589      $Output .= TableList(0);
  • page.php

    r8 r9  
    7070    $Output = $this->ShowHeader($this->FullTitle, $this->ShortTitle).$Output;
    7171    //$Output .= $this->ShowFooter();
    72     //echo($this->FormatOutput($Output));
     72    //$Output = $this->FormatOutput($Output);
    7373    echo($Output);
    7474  }
  • style.css

    r8 r9  
    3434.main div
    3535{
    36   font-weight: bold;
    3736}
    3837
  • types/Hyperlink.php

    r8 r9  
    33function TypeHyperlinkViewHtml($Type, $Item)
    44{
    5   $Output = '<a href="'.$Item['Name'].'">'.$Item['Value'].'</a>';
     5  $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>';
    66  return($Output);
    77}
    88
    9 function TypeHyperlinkEditHtml($Type, $Parameter, $Table, $Id)
     9function TypeHyperlinkEditHtml($Type, $Item)
    1010{
    1111  $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
  • types/Password.php

    r8 r9  
    11<?php
    22
    3 function TypePasswordViewHtml($Type, $Parameter, $Table, $Id)
     3function TypePasswordViewHtml($Type, $Item)
    44{
    55  $Output = '';
     
    99}
    1010
    11 function TypePasswordEditHtml($Type, $Parameter, $Table, $Id)
     11function TypePasswordEditHtml($Type, $Item)
    1212{
    1313  $Output = '<input type="password" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
  • types/PointerOneToOne.php

    r8 r9  
    11<?php
    22
    3 function TypePointerOneToOneViewHtml($Type, $Item)
     3function GetTablePointerName($Type, $Item)
    44{
    55  global $Database, $Lists;
    66
    7   //print_r($Type);
    8   $Output = '';
    97  $Columns = '';
    108  $ItemType = explode(':', $Item['Type']);
     
    1816  if($DbResult->num_rows > 0)
    1917  {
    20     $DbRow = $DbResult->fetch_array();
    21     $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$DbRow['Id'].'">'.$DbRow['Name'].'</a>';
    22   }
     18    return($DbResult->fetch_assoc());
     19  } else return('');
     20}
     21
     22function GetTablePointerNameList($Type, $Item)
     23{
     24  global $Database, $Lists;
     25
     26  $Columns = '';
     27  $ItemType = explode(':', $Item['Type']);
     28  $TargetTable = $ItemType[1];
     29
     30  foreach($Lists[$TargetTable]['Items'] as $ListItem)
     31    if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
     32  $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
     33  $DbResult = $Database->select($TargetTable, $Columns);
     34  //echo($Database->LastQuery);
     35  if($DbResult->num_rows > 0)
     36  {
     37    $Result = array();
     38    while($DbRow = $DbResult->fetch_assoc())
     39      $Result[] = $DbRow;
     40    return($Result);
     41  } else return(array());
     42}
     43
     44function TypePointerOneToOneViewHtml($Type, $Item)
     45{
     46  global $Database, $Lists;
     47
     48  $ItemType = explode(':', $Item['Type']);
     49  $TargetTable = $ItemType[1];
     50  $TargetName = GetTablePointerName($Type, $Item);
     51  $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName['Id'].'">'.$TargetName['Name'].'</a>';
    2352  return($Output);
    2453}
     
    2958
    3059  $Output = '<select name="'.$Item['Name'].'">';
    31   $Columns = '';
    32   $ItemType = explode(':', $Item['Type']);
    33   $TargetTable = $ItemType[1];
    34   foreach($Lists[$TargetTable]['Items'] as $ListItem)
    35     if($ListItem['VisibleInPointer'] == 1) $Columns .= '`'.$ListItem['Name'].'`," ",';
    36   $Columns = 'CONCAT('.substr($Columns, 0, -1).') AS Name, Id';
    37   $DbResult = $Database->select($TargetTable, $Columns);
     60  $TargetNameList = GetTablePointerNameList($Type, $Item);
    3861  //echo($Database->LastQuery);
    39   while($DbRow = $DbResult->fetch_array())
     62  foreach($TargetNameList as $TargetName)
    4063  {
    41     if($Parameter == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';
    42     $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>';
     64    if($Item['Value'] == $TargetName['Id']) $Selected = ' selected="1"'; else $Selected = '';
     65    $Output .= '<option value="'.$TargetName['Id'].'"'.$Selected.'>'.$TargetName['Name'].'</option>';
    4366  }
    4467  $Output .= '</select>';
  • user.php

    r8 r9  
    6868    while($DbRow = $DbResult->fetch_array())
    6969    {
    70       $this->Database->delete($this->TableUserOnline, 'Id='.$DbRow['User']);
     70      $this->Database->delete($this->TableUserOnline, 'User='.$DbRow['User']);
    7171      $this->System->Modules['Log']->NewRecord('User', 'Logout');
    7272    }
     
    9696          $this->Database->insert($this->TableUser, array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => sha1($Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1));
    9797          $UserId = $this->Database->insert_id;
    98          
     98
    9999          $Subject = FromUTF8('Registrace nového účtu', 'iso2');
    100100          $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder']."</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Nick."\n<br>Pro dokončení registrace klikněte na ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&amp;User='.$UserId.'&amp;H='.sha1($Password).'">tento odkaz</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte.";
Note: See TracChangeset for help on using the changeset viewer.