Changeset 15 for base.php


Ignore:
Timestamp:
Oct 19, 2008, 8:16:37 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Mezitabulkovéí odkazy na položky jsou nyní realizovány jako odkazy na id položky(ItemId) namísto id řádku v tabulce(Id).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • base.php

    r14 r15  
    44{
    55  global $Database, $Types, $Config;
     6
     7  //if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    68
    79  if($Title == '') $Output = '<div>'.$List['Title'].'</div>';
     
    3234  {
    3335    if($_SESSION['OrderColumn'] == $_GET['OrderColumn']) // Same column => reverse orded
    34       $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2; 
     36      $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2;
    3537    if($_SESSION['OrderTable'] != $List['TableName']) // Different table => set ascending order
    3638      $_SESSION['OrderDirection'] = 0;
     
    6365      }
    6466    }
    65     $Output .= '<td><a href="?Action=ViewItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['Id'].'">Zobrazit</a> <a href="?Action=EditItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['Id'].'">Editovat</a> <a href="?Action=DeleteItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['Id'].'">Smazat</a></td></tr>';
     67    $Output .= '<td><a href="?Action=ViewItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'">Zobrazit</a> <a href="?Action=EditItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'">Editovat</a> <a href="?Action=DeleteItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'">Smazat</a></td></tr>';
    6668  }
    6769  $Output .= '</table>';
     
    7476function ShowHistory($List, $Id, $Title = '')
    7577{
    76   global $Database, $Types, $Config;
     78  global $Database, $Types, $Config, $TypeNames;
    7779
    7880  if($Title == '') $Output = '<div>'.$List['Title'].'</div>';
     
    125127      }
    126128    }
    127     $Item = array('Name' => 'Author', 'Type' => 'PointerOneToOne:User');
    128     $ItemType = explode(':', $Item['Type']);
     129    echo($TypeNames['PointerOneToUser']);
     130    $Item = array('Name' => 'Author', 'Type' => $TypeNames['PointerOneToUser']);
     131    $ItemType = explode('|', $Types[$Item['Type']]['Parameters']);
    129132    $Type = $Types[$ItemType[0]];
    130133    $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     
    146149  global $Database, $Types;
    147150
    148   $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id);
     151  $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1');
    149152  while($DbRow = $DbResult->fetch_array())
    150153  {
     
    181184  global $Database, $Types, $System, $LogActionType;
    182185
    183   $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id);
     186  $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1');
    184187  while($DbRow = $DbResult->fetch_array())
    185188  {
     
    205208  $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Edit']);
    206209  $Output = 'Změny uloženy.';
    207   $Output .= ShowViewItem($List, $NewId);
     210  $Output .= ShowViewItem($List, $Id);
    208211  $Form->Values['Column'] = $_POST['Column'];
    209212  ExecuteListEvent($List['TableName'], 'OnEdit', $Form->Values);
     
    279282  );
    280283  $Form->LoadValuesFromForm();
    281   $System->Modules['DatabaseList']->AddItem($List['TableName'], $Form->Values);
     284  $NewItemId = $System->Modules['DatabaseList']->AddItem($List['TableName'], $Form->Values);
    282285  $NewId = $Database->insert_id;
    283   $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']);
     286   $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']);
    284287  $Output = 'Položka přidána';
    285   $Output .= ShowViewItem($List, $NewId);
     288  $Output .= ShowViewItem($List, $NewItemId);
    286289  $Form->Values['Column'] = $_POST['Column'];
    287290  ExecuteListEvent($List['TableName'], 'OnAdd', $Form->Values);
     
    294297
    295298  $Output = '';
    296   $DbResult = $Database->select($List['TableName'], '*', 'Id='.$Id);
     299  $DbResult = $Database->select($List['TableName'], '*', 'ItemId='.$Id.' ORDER BY Id DESC LIMIT 1');
    297300  while($DbRow = $DbResult->fetch_array())
    298301  {
     
    312315    );
    313316    $Output .= $Form->ShowReadOnlyForm();
    314     $Output .= '<a href="?Action=EditItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['Id'].'">Editovat</a> ';
     317    $Output .= '<a href="?Action=EditItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'">Editovat</a> ';
    315318
    316319    if(($Column != '') and ($ColumnValue != 0))
     
    328331      {
    329332        $SubList = $Lists[$Types[$Item['Type']]['Parameters'][0]];
    330         $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['Id'], $Item['TextBefore']).'<br /><br />';
     333        $Output .= ShowList($SubList, $Types[$Item['Type']]['Parameters'][1], $DbRow['ItemId'], $Item['TextBefore']).'<br /><br />';
    331334      }
    332335    }
     
    418421  global $Database, $Lists;
    419422
    420   $DbResult = $Database->select('SystemList', '*');
     423  $DbResult = $Database->query('SELECT t1.* FROM `SystemList` AS t1 LEFT JOIN `SystemList` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)');
    421424  while($DbRow = $DbResult->fetch_assoc())
    422425  {
    423426    $Items = array();
    424     $DbResult2 = $Database->select('SystemListItem', '`Id`, `Name`, `TextBefore`, `TextAfter`, `Type`, `Default`, `Help`, `Required`, `Editable`, `VisibleInList`, `VisibleInPointer`', 'List='.$DbRow['Id']);
     427    $DbResult2 = $Database->query('SELECT t1.* FROM `SystemListItem` AS t1 LEFT JOIN `SystemListItem` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND t1.List='.$DbRow['ItemId']);
    425428    while($DbRow2 = $DbResult2->fetch_assoc())
    426429    {
     
    437440    $Lists[$List['TableName']] = $List;
    438441  }
     442  //print_r($Lists);
    439443}
    440444
     
    445449  $Types = array();
    446450  $TypeNames = array();
    447   $DbResult = $Database->select('SystemType', '*');
     451  $DbResult = $Database->query('SELECT t1.* FROM `SystemType` AS t1 LEFT JOIN `SystemType` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL)');
    448452  while($DbRow = $DbResult->fetch_assoc())
    449453  {
    450454    $DbRow['Parameters'] = explode('|', $DbRow['Parameters']);
    451455    $DbRow['BaseType'] = $DbRow['Name'];
    452     $Types[$DbRow['Id']] = $DbRow;
    453     $TypeNames[$DbRow['Name']] = $DbRow['Id'];
     456    $Types[$DbRow['ItemId']] = $DbRow;
     457    $TypeNames[$DbRow['Name']] = $DbRow['ItemId'];
    454458  }
    455459
     
    483487  //echo($Callback.',');
    484488  if(is_callable($Callback)) return($Callback($Parameters));
    485     else return($Callback);
     489    else return($Callback.'('.$Type.')');
    486490}
    487491
     
    497501}
    498502
     503function CheckPermission($Right, $ListId, $ItemId = 0)
     504{
     505  global $Database;
     506
     507  $DbResult = $Database->query('SELECT t1.* FROM `Permission` AS t1 LEFT JOIN `Permission` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND t1.PermissionGroup = (SELECT PermissionGroup.Id FROM PermissionGroup WHERE PermissionGroup.Id=(SELECT User.PermissionGroup FROM User WHERE User.ItemId='.$System->Modules['User']->User['Id'].' ORDER BY User.Id DESC LIMIT 1) ORDER BY PermissionGroup.Id DESC LIMIT 1) AND t1.DeletionTime IS NULL AND t1.List='.$ListId);
     508  if($DbResult->num_rows > 0)
     509  {
     510    $DbRow = $DbResult->fetch_assoc();
     511    switch($DbRow['Right'])
     512    {
     513      case 0: return(array('Read' => FALSE, 'Write' => FALSE));
     514      case 1: return(array('Read' => TRUE, 'Write' => FALSE));
     515      case 2: return(array('Read' => TRUE, 'Write' => TRUE));
     516    }
     517  }
     518}
     519
    499520?>
Note: See TracChangeset for help on using the changeset viewer.