Changeset 30


Ignore:
Timestamp:
Dec 16, 2008, 8:15:34 AM (16 years ago)
Author:
george
Message:
  • Přidáno: Podpora pro určování v definicích krom tabulky také jméno databáze a jméno primárního identifikačního sloupce.
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • base.php

    r29 r30  
    11<?php
     2
     3function GetListTableName($List)
     4{
     5  if($List['Database'] != '') return('`'.$List['Database'].'`.`'.$List['TableName'].'`');
     6  else return('`'.$List['TableName'].'`');
     7}
    28
    39function ShowList($List, $Column = '', $ColumnValue = 0, $Title = '', $Filter = '')
     
    5460  //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))';
    5561  $Where .= ' '.$Order;
    56   $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM `'.$List['TableName'].'` WHERE '.$Where);
     62  $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM '.GetListTableName($List).' WHERE '.$Where);
    5763  $DbRow = $DbResult->fetch_row();
    5864  $TotalItemCount = $DbRow[0];
    5965
    60   $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'` WHERE '.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);
     66  $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);
    6167  //echo($Database->LastQuery);
    6268  while($DbRow = $DbResult->fetch_assoc())
     
    6773      if($Item['VisibleInList'] == 1)
    6874      {
    69         $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     75        $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']);
    7076        $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>';
    7177      }
    7278    }
    7379    $Output .= '<td>';
    74     if(CheckPermission('Read', $List['Id'])) $Output .= '<a href="?Action=ViewItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow['Id'].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>';
    75     if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=EditItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow['Id'].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>';
    76     if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=DeleteItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow['Id'].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat" onclick="return confirmAction(\'Opravdu smazat položku?\');"></a>';
     80    if(CheckPermission('Read', $List['Id'])) $Output .= '<a href="?Action=ViewItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>';
     81    if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=EditItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>';
     82    if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=DeleteItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat" onclick="return confirmAction(\'Opravdu smazat položku?\');"></a>';
    7783    $Output .= '</td></tr>';
    7884  }
     
    158164
    159165  if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    160   $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id);
     166  $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id);
    161167  while($DbRow = $DbResult->fetch_assoc())
    162168  {
     
    169175        if($Item['Editable'] == 1)
    170176        {
    171           $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     177          $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']);
    172178        } else $DefinitionItems[] = array('Name' => $Index, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $DbRow[$Index]);
    173179      }
     
    198204
    199205  if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    200   $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id);
     206  $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id);
    201207  while($DbRow = $DbResult->fetch_assoc())
    202208  {
     
    207213      if($Type['BaseType'] != 'PointerOneToMany')
    208214      {
    209         $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     215        $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']);
    210216      }
    211217    }
     
    227233  $Form->Values['Id'] = $Id;
    228234  $Form->Values['ListTableName'] = $List['TableName'];
     235  $Form->Values['ListDatabaseName'] = $List['Database'];
    229236  ExecuteListEvent($List['Id'], 'OnEdit', $Form->Values);
    230237  return($Output);
     
    320327  if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    321328  $Output = '';
    322   $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id);
     329  $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id);
    323330  while($DbRow = $DbResult->fetch_assoc())
    324331  {
     
    340347    );
    341348    $Output .= $Form->ShowReadOnlyForm();
    342     if(CheckPermission('Write', $List['Id'])) $Output .= '<a href="?Action=EditItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow['Id'].'">Editovat</a> ';
     349    if(CheckPermission('Write', $List['Id'])) $Output .= '<a href="?Action=EditItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow[$List['IdName']].'">Editovat</a> ';
    343350
    344351    if(($Column != '') and ($ColumnValue != 0))
     
    349356      $Output .= '<a href="?Action=ShowList&amp;Table='.$List['Id'].'">Celkový seznam</a>';
    350357    }
    351     $Output .= ' <a href="?Action=ShowHistory&amp;Table='.$List['Id'].'&amp;Item='.$DbRow['Id'].'">Historie</a>';
    352     $Output .= ' <a href="?Action=DeleteItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow['Id'].'"  onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';
     358    $Output .= ' <a href="?Action=ShowHistory&amp;Table='.$List['Id'].'&amp;Item='.$DbRow[$List['IdName']].'">Historie</a>';
     359    $Output .= ' <a href="?Action=DeleteItem&amp;Table='.$List['Id'].'&amp;Item='.$DbRow[$List['IdName']].'"  onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';
    353360    $Output .= '<div class="line"></div>';
    354361    foreach($List['Items'] as $Index => $Item)
     
    358365      {
    359366        $SubList = GetListDefinition($Type['Parameters'][0]);
    360         $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow['Id'], $Item['TextBefore']).'<br /><br />';
     367        $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow[$List['IdName']], $Item['TextBefore']).'<br /><br />';
    361368      }
    362369    }
     
    472479    while($DbRow2 = $DbResult2->fetch_assoc())
    473480    {
    474       if(CheckPermission('Read', $DbRow2['Id']))
     481      if(CheckPermission('Read', $DbRow2[$List['IdName']]))
    475482        $Group .= '<a href="?Action=ShowList&amp;Table='.$DbRow2['Id'].'">'.$DbRow2['Title'].'</a><br />';
    476483    }
     
    485492function Output()
    486493{
     494  //print_r($_SESSION);
    487495  $PermanentVar = array('Table', 'Item', 'Column', 'ColumnValue', 'Action');
    488496  if($_GET['Table'] != $_SESSION['Table'])
     
    496504  }
    497505  $Output = '';
    498   if(array_key_exists('Table', $_SESSION))
     506  if(array_key_exists('Table', $_SESSION) and ($_SESSION['Table'] != ''))
    499507  {
    500508    $List = GetListDefinition($_SESSION['Table']);
     
    561569       'Id' => $DbRow['Id'],
    562570       'TableName' => $DbRow['TableName'],
     571       'Database' => $DbRow['Database'],
    563572       'Title' => $DbRow['Title'],
     573       'IdName' => $DbRow['IdName'],
    564574       'Items' => $Items,
    565575      );
     
    643653  global $Database;
    644654
    645   $DbResult = $Database->select('SystemList', '*');
     655  $DbResult = $Database->select(array('Table' => 'SystemList'));
    646656  while($DbRow = $DbResult->fetch_assoc())
    647657  {
  • database.php

    r24 r30  
    22
    33// Extended database class
    4 // Date: 2008-10-13
     4// Date: 2008-12-15
    55
    66class Database extends mysqli
     
    1616    if(($this->ShowError == TRUE) and ($this->error != ''))
    1717    {
    18       echo('<strong>Database error:</strong> '.$this->error.'<br /><strong>Query:</strong> '.$Query.'<br />');
     18      echo('<strong>Database error:</strong> '.$this->error.'<br />');
     19      echo('<strong>Query:</strong> '.$Query.'<br />');
    1920      echo('<pre style="font-size: 9px">'); print_r(debug_backtrace()); echo('</pre>');
    2021    }
     
    2223  }
    2324
    24   function select($Table, $What = '*', $Condition = 1)
     25  function select($Parameters) // Database, Table, Columns, Condition, Order
    2526  {
    26     return($this->query("SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition));
     27    $Query = 'SELECT ';
     28    if(array_key_exists('Columns', $Parameters)) $Query .= $Parameters['Columns']; else $Query .= '*';
     29    $Query .= ' FROM ';
     30    if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.';
     31    $Query .= '`'.$this->Prefix.$Parameters['Table'].'`';
     32    if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition'];
     33    return($this->query($Query));
    2734  }
    2835
    29   function delete($Table, $Condition)
     36  function delete($Parameters)
    3037  {
    31     $this->query("DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition);
     38    $Query = 'DELETE FROM ';
     39    if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.';
     40    $Query .= '`'.$this->Prefix.$Parameters['Table'].'`';
     41    if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition'];
     42    $this->query($Query);
    3243  }
    3344
    34   function insert($Table, $Data)
     45  function insert($Parameters, $Data)
    3546  {
    3647    $Name = '';
     
    4556    $Name = substr($Name, 1);
    4657    $Values = substr($Values, 1);
    47     $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
     58    $Query = 'INSERT INTO ';
     59    if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.';
     60    $Query .= '`'.$this->Prefix.$Parameters['Table'].'`';
     61    $Query .= ' ('.$Name.') VALUES ('.$Values.')';
     62    $this->query($Query);
    4863  }
    4964
    50   function update($Table, $Condition, $Data)
     65  function update($Parameters, $Data)
    5166  {
    5267    $Values = '';
     
    5873    }
    5974    $Values = substr($Values, 2);
    60     $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
     75    $Query = 'UPDATE ';
     76    if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.';
     77    $Query .= '`'.$this->Prefix.$Parameters['Table'].'`';
     78    $Query .= ' SET '.$Values;
     79    if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition'];
     80    $this->query($Query);
    6181  }
    6282
    63   function replace($Table, $Data)
     83  function replace($Parameters, $Data)
    6484  {
    6585    $Name = '';
     
    7595    $Values = substr($Values, 1);
    7696    //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br>');
    77     $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
     97    $Query = 'REPLACE INTO ';
     98    if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.';
     99    $Query .= '`'.$this->Prefix.$Parameters['Table'].'`';
     100    $Query .= ' ('.$Name.') VALUES ('.$Values.')';
     101    $this->query($Query);
    78102  }
    79103
  • database_list.php

    r28 r30  
    77  function AddItem($TableId, $Values)
    88  {
    9     $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId);
     9    $DbResult = $this->Database->query('SELECT `TableName`, `Database` FROM `SystemList` WHERE `Id`='.$TableId);
    1010    $DbRow = $DbResult->fetch_assoc();
    1111    $TableName = $DbRow['TableName'];
    1212
    13     $this->Database->insert($TableName, $Values);
     13    $this->Database->insert(array('Table' => $TableName), $Values);
    1414    return($this->Database->insert_id);
    1515  }
     
    1717  function DeleteItem($TableId, $ItemId)
    1818  {
    19     $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId);
     19    $DbResult = $this->Database->query('SELECT `TableName`, `Database` FROM `SystemList` WHERE `Id`='.$TableId);
    2020    $DbRow = $DbResult->fetch_assoc();
    2121    $TableName = $DbRow['TableName'];
    22     $this->Database->delete($TableName, 'Id='.$ItemId, array('DeletionTime' => 'NOW()'));
     22    $this->Database->delete(array('Table' => $TableName, 'Condition' => 'Id='.$ItemId), array('DeletionTime' => 'NOW()'));
    2323  }
    2424
    2525  function EditItem($TableId, $Values, $ItemId)
    2626  {
    27     $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId);
     27    $DbResult = $this->Database->query('SELECT `TableName`, `Database` FROM `SystemList` WHERE `Id`='.$TableId);
    2828    $DbRow = $DbResult->fetch_assoc();
    2929    $TableName = $DbRow['TableName'];
    3030    $this->DeleteItem($TableId, $ItemId);
    3131    $Values['Id'] = $ItemId;
    32     $this->Database->replace($TableName, $Values);
     32    $this->Database->replace(array('Table' => $TableName), $Values);
    3333  }
    3434}
  • install/system_init.php

    r29 r30  
    11<?php
    22
    3 $SytemList = array();
     3function TableStructure()
     4{
     5  global $Database;
     6 
     7  $Database->query('CREATE TABLE IF NOT EXISTS `SystemType` (
     8  `Id` int(11) NOT NULL auto_increment,
     9  `Name` varchar(255) collate utf8_czech_ci NOT NULL,
     10  `Description` varchar(255) collate utf8_czech_ci NOT NULL,
     11  `ParentType` int(255) NOT NULL,
     12  `Parameters` varchar(255) collate utf8_czech_ci NOT NULL,
     13  `System` tinyint(1) NOT NULL default '0',
     14  `DbDataType` varchar(255) collate utf8_czech_ci NOT NULL,
     15  `ParameterList` int(11) NOT NULL,
     16  PRIMARY KEY  (`Id`)
     17) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     18  $Database->query("INSERT INTO `SystemType` (`Id`, `Name`, `Description`, `ParentType`, `Parameters`, `System`, `DbDataType`, `ParameterList`) VALUES
     19(1, 'Integer', 'Číslo', 0, '', 1, 'INT', 0),
     20(2, 'Date', 'Datum', 0, '', 1, 'DATE', 0),
     21(3, 'String', 'Řetězec', 0, '', 1, 'VARCHAR(255)', 0),
     22(4, 'Boolean', 'Logická hodnota', 0, '', 1, 'BOOL', 0),
     23(5, 'Float', 'Desetinné číslo', 0, '', 1, 'FLOAT', 0),
     24(6, 'Enumeration', 'Výčet', 0, '', 0, 'INT', 0),
     25(7, 'PointerOneToOne', 'Ukazatel na jednu položku', 0, '', 1, 'INT', 0),
     26(8, 'PointerOneToMany', 'Ukazatel na více položek', 0, '', 1, 'INT', 0),
     27(9, 'Password', 'Heslo', 0, '', 1, 'INT', 0),
     28(10, 'Hyperlink', 'Internetový odkaz', 0, '', 0, 'VARCHAR(255)', 0),
     29(11, 'IPv4Address', 'IP adresa v4', 0, '', 0, 'VARCHAR(16)', 0),
     30(12, 'Hidden', 'Skrytá položka formuláře', 0, '', 1, 'VARCHAR(255)', 0),
     31(13, 'DateTime', 'Datum a čas', 0, '', 1, 'DATETIME', 0),
     32(14, 'File', 'Soubor', 0, '', 1, 'INT', 0),
     33(15, 'GPS', 'Zemská souřadnice', 0, '', 1, 'INT', 0),
     34(16, 'MySQLDataTypes', 'Databázový datový typ ', 14, 'INT|VARCHAR(255)|TEXT|FLOAT|DOUBLE|TIME|DATE|DATETIME|', 1, 'INT', 0),
    435
     36(17, 'Sex', 'Pohlaví', 14, 'Muž|Žena', 0, 'INT', 0),
     37(18, 'PointerToSystemListItemList', '', 13, 'SystemListItem|List', 0, 'INT', 0),
     38(19, 'PointerToSystemList', '', 12, 'SystemList', 0, 'INT', 0),
     39(20, 'PointerToSystemType', '', 12, 'SystemType', 0, 'INT', 0),
     40(21, 'PointerToMenu', 'Ukazatel na menu', 12, 'SystemMenu', 0, 'INT', 0),
     41(22, 'PointerToSystemListMenu', 'Položky menu', 13, 'SystemList|Menu', 0, 'INT', 0),
     42(23, 'PointerToSystemTypeParameter', 'Ukazatel na seznam paramtrů', 13, 'SystemTypeParameter|ParentType', 0, 'INT', 0),
     43(24, 'PointerToSystemEnumerationState', 'Seznam stavů výčtu', 13, 'SystemEnumerationState|ParentType', 0, 'INT', 0);");
     44
     45  $Database->query('CREATE TABLE IF NOT EXISTS `SystemEnumerationState` (
     46  `Id` int(11) NOT NULL auto_increment,
     47  `Name` varchar(255) collate utf8_czech_ci NOT NULL,
     48  `ParentParameter` int(11) NOT NULL,
     49  PRIMARY KEY  (`Id`)
     50) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     51  $Database->query('CREATE TABLE IF NOT EXISTS `SystemFile` (
     52  `Id` int(11) NOT NULL auto_increment,
     53  `Name` varchar(255) collate utf8_czech_ci NOT NULL,
     54  `Size` int(11) NOT NULL,
     55  PRIMARY KEY  (`Id`)
     56) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     57  $Database->query('CREATE TABLE IF NOT EXISTS `SystemGPS` (
     58  `Id` int(11) NOT NULL auto_increment,
     59  `Longitude` double NOT NULL,
     60  `Latitude` double NOT NULL,
     61  PRIMARY KEY  (`Id`)
     62) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     63  $Database->query('CREATE TABLE IF NOT EXISTS `SystemList` (
     64  `Id` int(11) NOT NULL auto_increment,
     65  `TableName` varchar(255) collate utf8_czech_ci NOT NULL,
     66  `Title` varchar(255) collate utf8_czech_ci NOT NULL,
     67  `Items` varchar(255) collate utf8_czech_ci NOT NULL,
     68  `Menu` int(11) NOT NULL,
     69  `Sequence` int(11) NOT NULL,
     70  PRIMARY KEY  (`Id`)
     71) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     72  $Database->query('CREATE TABLE IF NOT EXISTS `SystemListItem` (
     73  `Id` int(11) NOT NULL auto_increment,
     74  `Name` varchar(255) collate utf8_czech_ci NOT NULL,
     75  `TextBefore` varchar(255) collate utf8_czech_ci NOT NULL,
     76  `TextAfter` varchar(255) collate utf8_czech_ci NOT NULL,
     77  `Type` varchar(255) collate utf8_czech_ci NOT NULL,
     78  `Help` varchar(255) collate utf8_czech_ci NOT NULL,
     79  `Default` varchar(255) collate utf8_czech_ci NOT NULL,
     80  `Required` tinyint(1) NOT NULL default '1',
     81  `Editable` tinyint(1) NOT NULL default '1',
     82  `VisibleInList` tinyint(1) NOT NULL default '0',
     83  `VisibleInPointer` tinyint(1) NOT NULL default '0',
     84  `List` int(11) NOT NULL,
     85  `Sequence` int(11) NOT NULL,
     86  PRIMARY KEY  (`Id`)
     87) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     88  $Database->query('CREATE TABLE IF NOT EXISTS `SystemLog` (
     89  `Id` int(11) NOT NULL auto_increment,
     90  `User` int(11) NOT NULL,
     91  `List` int(11) NOT NULL,
     92  `Item` int(11) NOT NULL,
     93  `Action` int(11) NOT NULL,
     94  PRIMARY KEY  (`Id`)
     95) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     96  $Database->query('CREATE TABLE IF NOT EXISTS `SystemMenu` (
     97  `Id` int(11) NOT NULL auto_increment,
     98  `Name` varchar(255) collate utf8_czech_ci NOT NULL,
     99  `SystemListItems` int(11) NOT NULL,
     100  `Sequence` int(11) NOT NULL,
     101  PRIMARY KEY  (`Id`)
     102) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     103  $Database->query('CREATE TABLE IF NOT EXISTS `SystemType` (
     104  `Id` int(11) NOT NULL auto_increment,
     105  `Name` varchar(255) collate utf8_czech_ci NOT NULL,
     106  `Description` varchar(255) collate utf8_czech_ci NOT NULL,
     107  `ParentType` int(255) NOT NULL,
     108  `Parameters` varchar(255) collate utf8_czech_ci NOT NULL,
     109  `System` tinyint(1) NOT NULL default '0',
     110  `DbDataType` varchar(255) collate utf8_czech_ci NOT NULL,
     111  `ParameterList` int(11) NOT NULL,
     112  PRIMARY KEY  (`Id`)
     113) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     114  $Database->query('CREATE TABLE IF NOT EXISTS `SystemTypeParameter` (
     115  `Id` int(11) NOT NULL auto_increment,
     116  `Name` varchar(255) collate utf8_czech_ci NOT NULL,
     117  `Type` int(11) NOT NULL,
     118  `ParentType` int(11) NOT NULL,
     119  `Description` varchar(255) collate utf8_czech_ci NOT NULL,
     120  PRIMARY KEY  (`Id`)
     121) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci');
     122  $Database->query('CREATE TABLE IF NOT EXISTS `SystemTypeParameterValue` (
     123  `Id` int(11) NOT NULL auto_increment,
     124  PRIMARY KEY  (`Id`)
     125) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;');
     126  $Database->query('CREATE TABLE IF NOT EXISTS `User` (
     127  `Id` int(11) NOT NULL auto_increment,
     128  `UserName` varchar(255) collate utf8_czech_ci NOT NULL,
     129  `Password` varchar(255) collate utf8_czech_ci NOT NULL,
     130  `FirstName` varchar(255) character set ucs2 collate ucs2_czech_ci NOT NULL,
     131  `SecondName` varchar(255) character set ucs2 collate ucs2_czech_ci NOT NULL,
     132  `Email` varchar(255) character set ucs2 collate ucs2_czech_ci NOT NULL,
     133  `ICQ` int(11) NOT NULL,
     134  `Sex` int(11) NOT NULL default '0',
     135  `BirthDay` date NOT NULL,
     136  `Phone` varchar(255) collate utf8_czech_ci NOT NULL,
     137  `Member` int(11) NOT NULL,
     138  `RegistrationTime` datetime NOT NULL,
     139  `LastLoginTime` datetime NOT NULL,
     140  `Locked` tinyint(1) NOT NULL,
     141  `LastIpAddress` varchar(255) collate utf8_czech_ci NOT NULL,
     142  `PermissionGroup` int(11) NOT NULL,
     143  PRIMARY KEY  (`Id`)
     144) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci');
     145  $Database->query('CREATE TABLE IF NOT EXISTS `UserOnline` (
     146  `User` int(11) NOT NULL,
     147  `LoginTime` datetime NOT NULL,
     148  `ActivityTime` datetime NOT NULL,
     149  `SessionId` varchar(255) collate utf8_czech_ci NOT NULL,
     150  `IpAddress` varchar(16) collate utf8_czech_ci NOT NULL,
     151  `HostName` varchar(255) collate utf8_czech_ci NOT NULL,
     152  `Id` int(11) NOT NULL auto_increment,
     153  PRIMARY KEY  (`Id`),
     154  KEY `User` (`User`)
     155) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci');
     156
     157}
     158
     159function LoadInitData()
     160{
     161
     162}
    5163
    6164?>
  • types/PointerOneToOne.php

    r29 r30  
    2323        {
    2424          //print_r($Type);
    25           $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Item['Value']);
     25          $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $List['TableName'], 'Condition' => 'Id='.$Item['Value']));
    2626          $DbRow = $DbResult->fetch_assoc();
    2727          $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0);
     
    3434    if($Columns == '') $Columns = 'Id AS Name, Id';
    3535      else $Columns = 'CONCAT('.$Columns.') AS Name, Id';
    36     $DbResult = $Database->select($TargetTable, $Columns, 'Id='.$Item['Value']);
     36    $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns, 'Condition' => 'Id='.$Item['Value']));
    3737    //echo($Database->LastQuery);
    3838    if($DbResult->num_rows > 0)
  • user.php

    r28 r30  
    4141    $SID = session_id();
    4242    // Lookup user record
    43     $Query = $this->Database->select($this->TableUserOnline, '*', '`SessionId`="'.$SID.'"');
     43    $Query = $this->Database->select(array('Table' => $this->TableUserOnline, 'Condition' => '`SessionId`="'.$SID.'"'));
    4444    if($Query->num_rows > 0)
    4545    {
    4646      // Refresh time of last access
    47       $this->Database->update($this->TableUserOnline, '`SessionId`="'.$SID.'"', array('ActivityTime' => 'NOW()'));
    48     } else $this->Database->insert($this->TableUserOnline, array('SessionId' => $SID, 'User' => 0, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress())));
     47      $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => '`SessionId`="'.$SID.'"'), array('ActivityTime' => 'NOW()'));
     48    } else $this->Database->insert(array('Table' => $this->TableUserOnline), array('SessionId' => $SID, 'User' => 0, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress())));
    4949    //echo($this->Database->LastQuery);
    5050
    5151    // Zkontroluj přihlášení
    52     $Query = $this->Database->select($this->TableUserOnline, '*', 'SessionId="'.$SID.'"');
     52    $Query = $this->Database->select(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"'));
    5353    $Row = $Query->fetch_assoc();
    5454    if($Row['User'] != 0)
     
    6060    } else
    6161    {
    62       $Query = $this->Database->select($this->TableUser, '*', "`Id`=0");
     62      $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => "`Id`=0"));
    6363      $this->User = $Query->fetch_assoc();
    6464      $Result = USER_NOT_LOGGED;
     
    6666
    6767    // Odeber neaktivní uživatele
    68     $DbResult = $this->Database->select($this->TableUserOnline, 'User', '`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)');
     68    $DbResult = $this->Database->select(array('Table' => $this->TableUserOnline, 'Columns' => 'User', 'Condition' => '`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)'));
    6969    while($DbRow = $DbResult->fetch_assoc())
    7070    {
    71       $this->Database->delete($this->TableUserOnline, '`User`='.$DbRow['User']);
     71      $this->Database->delete(array('Table' => $this->TableUserOnline, 'Condition' => '`User`='.$DbRow['User']));
    7272      //$this->System->Modules['Log']->Add('User', 'Logout');
    7373    }
     
    8787    {
    8888      // Je uživatel registrován?
    89       $Query = $this->Database->select($this->TableUser, '*', 'Name = "'.$Nick.'"');
     89      $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'Name = "'.$Nick.'"'));
    9090      if($Query->num_rows > 0) $Result = NICK_USED;
    9191      else
    9292      {
    93         $Query = $this->Database->select($this->TableUser, '*', 'Email = "'.$Email.'"');
     93        $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'Email = "'.$Email.'"'));
    9494        if($Query->num_rows > 0) $Result = EMAIL_USED;
    9595        else
    9696        {
    97           $this->Database->insert($this->TableUser, array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => $Password, 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1));
     97          $this->Database->insert(array('Table' => $this->TableUser), array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => $Password, 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1));
    9898          $UserId = $this->Database->insert_id;
    9999
     
    112112  function RegisterConfirm($Id, $Hash)
    113113  {
    114     $DbResult = $this->Database->select($this->TableUser, 'Id, Name, Password', 'Id = '.$Id);
     114    $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Id, Name, Password', 'Condition' => 'Id = '.$Id));
    115115    if($DbResult->num_rows > 0)
    116116    {
     
    118118      if($Hash == $Row['Password'])
    119119      {
    120         $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('Locked' => 0));
     120        $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('Locked' => 0));
    121121        $Output = USER_REGISTRATION_CONFIRMED;
    122122        //$this->System->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'UserName='.$Row['Name']);
     
    130130    $SID = session_id();
    131131    // Je uživatel registrován?
    132     $Query = $this->Database->select($this->TableUser, '*', 'UserName="'.$Nick.'"');
     132    $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'UserName="'.$Nick.'"'));
    133133    if($Query->num_rows > 0)
    134134    {
     
    138138      else
    139139      {
    140         $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()'));
    141         $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => $Row['Id'], 'Id' => $Row['mId']));
     140        $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('LastLoginTime' => 'NOW()'));
     141        $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"'), array('User' => $Row['Id'], 'Id' => $Row['mId']));
    142142        // načtení stavu stromu
    143143        $Result = USER_LOGGED_IN;
     
    154154
    155155    $SID = session_id();
    156     $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => 0));
     156    $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"'), array('User' => 0));
    157157    //$this->System->Modules['Log']->NewRecord('User', 'Logout', $this->User['Name']);
    158158    $this->Check();
     
    164164    global $Config;
    165165
    166     $DbResult = $this->Database->select($this->TableUser, 'Name, Id, Email, Password', '`Name`="'.$Name.'" AND `Email`="'.$Email.'"');
     166    $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Name, Id, Email, Password', 'Condition' => '`Name`="'.$Name.'" AND `Email`="'.$Email.'"'));
    167167    if($DbResult->num_rows > 0)
    168168    {
     
    182182  function PasswordRecoveryConfirm($Id, $Hash, $NewPassword)
    183183  {
    184     $DbResult = $this->Database->select($this->TableUser, 'Id, Name, Password', 'Id = '.$Id);
     184    $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Id, Name, Password', 'Condition' => 'Id = '.$Id));
    185185    if($DbResult->num_rows > 0)
    186186    {
     
    189189      if(($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))
    190190      {
    191         $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('Password' => $NewPassword, 'Locked' => 0));
     191        $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('Password' => $NewPassword, 'Locked' => 0));
    192192        $Output = USER_PASSWORD_RECOVERY_CONFIRMED;
    193193        //$this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'UserName='.$Row['Name']);
Note: See TracChangeset for help on using the changeset viewer.