Changeset 24 for base.php


Ignore:
Timestamp:
Oct 27, 2008, 5:10:59 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Odkazy na seznamy pomocí ItemId namísto jmen tabulek.
  • Přidáno: Potvrzovací dialog při mazání položek.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • base.php

    r23 r24  
    2727    $Where .= ' AND (t1.'.$Column.'='.$ColumnValue.')';
    2828    $ColumnSelection = '&Column='.$Column.'&ColumnValue='.$ColumnValue;
    29     $FullListLink = '<a href="?Action=ViewList&amp;Table='.$List['TableName'].'">Celkový seznam</a>';
     29    $FullListLink = '<a href="?Action=ViewList&amp;Table='.$List['ItemId'].'">Celkový seznam</a>';
    3030  } else
    3131  {
     
    3939    if($_SESSION['OrderColumn'] == $_GET['OrderColumn']) // Same column => reverse order
    4040      $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2;
    41     if($_SESSION['OrderTable'] != $List['TableName']) // Different table => set ascending order
     41    if($_SESSION['OrderTable'] != $List['ItemId']) // Different table => set ascending order
    4242      $_SESSION['OrderDirection'] = 0;
    4343    $_SESSION['OrderColumn'] = $_GET['OrderColumn'];
    44     $_SESSION['OrderTable'] = $List['TableName'];
    45   }
    46   if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['TableName']))
     44    $_SESSION['OrderTable'] = $List['ItemId'];
     45  }
     46  if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['ItemId']))
    4747  {
    4848    $OrderDirection = array('ASC', 'DESC');
     
    6666      if($Item['VisibleInList'] == 1)
    6767      {
    68         $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     68        $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['ItemId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
    6969        $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>';
    7070      }
    7171    }
    7272    $Output .= '<td>';
    73     if(CheckPermission('Read', $List['ItemId'])) $Output .= '<a href="?Action=ViewItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>';
    74     if(CheckPermission('Write', $List['ItemId'])) $Output .= ' <a href="?Action=EditItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>';
    75     if(CheckPermission('Write', $List['ItemId'])) $Output .= ' <a href="?Action=DeleteItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat"></a>';
     73    if(CheckPermission('Read', $List['ItemId'])) $Output .= '<a href="?Action=ViewItem&amp;Table='.$List['ItemId'].'&amp;Item='.$DbRow['ItemId'].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>';
     74    if(CheckPermission('Write', $List['ItemId'])) $Output .= ' <a href="?Action=EditItem&amp;Table='.$List['ItemId'].'&amp;Item='.$DbRow['ItemId'].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>';
     75    if(CheckPermission('Write', $List['ItemId'])) $Output .= ' <a href="?Action=DeleteItem&amp;Table='.$List['ItemId'].'&amp;Item='.$DbRow['ItemId'].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat" onclick="return confirmAction(\'Opravdu smazat položku?\');"></a>';
    7676    $Output .= '</td></tr>';
    7777  }
     
    7979  $PageList = PagesList($Page, $TotalItemCount);
    8080  if(strlen($PageList) != 0) $Output .= $PageList.'<br />';
    81   if(CheckPermission('Write', $List['ItemId'])) $Output .= ' <a href="?Action=AddItem&amp;Table='.$List['TableName'].$ColumnSelection.'">Přidat</a> '.$FullListLink;
     81  if(CheckPermission('Write', $List['ItemId'])) $Output .= ' <a href="?Action=AddItem&amp;Table='.$List['ItemId'].$ColumnSelection.'">Přidat</a> '.$FullListLink;
    8282  return($Output);
    8383}
     
    104104    if($_SESSION['OrderColumn'] == $_GET['OrderColumn']) // Same column => reverse orded
    105105      $_SESSION['OrderDirection'] = ($_SESSION['OrderDirection'] + 1) % 2;
    106     if($_SESSION['OrderTable'] != $List['TableName']) // Different table => set ascending order
     106    if($_SESSION['OrderTable'] != $List['ItemId']) // Different table => set ascending order
    107107      $_SESSION['OrderDirection'] = 0;
    108108    $_SESSION['OrderColumn'] = $_GET['OrderColumn'];
    109     $_SESSION['OrderTable'] = $List['TableName'];
    110   }
    111   if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['TableName']))
     109    $_SESSION['OrderTable'] = $List['ItemId'];
     110  }
     111  if(array_key_exists('OrderColumn', $_SESSION) and ($_SESSION['OrderTable'] == $List['ItemId']))
    112112  {
    113113    $OrderDirection = array('ASC', 'DESC');
     
    132132      if($Item['VisibleInList'] == 1)
    133133      {
    134         $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     134        $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['ItemId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
    135135        $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>';
    136136      }
    137137    }
    138138    $Item = array('Name' => 'Author', 'Type' => TypePointerToUserId);
    139     $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     139    $ItemDefinition = array('Name' => $Item['Name'], 'Value' => $DbRow[$Item['Name']], 'SourceTable' => $List['ItemId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
    140140    $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>';
    141141
    142142    $Output .= '<td>'.$DbRow['CreationTime'].'</td><td>'.$DbRow['DeletionTime'].'</td>';
    143     $Output .= '<td><a href="?Action=ViewItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['Id'].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a></td></tr>';
     143    $Output .= '<td><a href="?Action=ViewItem&amp;Table='.$List['ItemId'].'&amp;Item='.$DbRow['Id'].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a></td></tr>';
    144144  }
    145145  $Output .= '</table>';
    146146  $Output .= PagesList($Page, $TotalItemCount);
    147   $Output .= ' <a href="?Action=ShowList&amp;Table='.$List['TableName'].'">Celkový seznam</a>';
     147  $Output .= ' <a href="?Action=ShowList&amp;Table='.$List['ItemId'].'">Celkový seznam</a>';
    148148  return($Output);
    149149}
     
    165165        if($Item['Editable'] == 1)
    166166        {
    167           $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     167          $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['ItemId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
    168168        } else $DefinitionItems[] = array('Name' => $Index, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $DbRow[$Index]);
    169169      }
     
    181181  if(($Column != '') and ($ColumnValue != 0))
    182182  {
    183     $Output .= '<a href="?Action=ShowList&amp;Table='.$List['TableName'].'&amp;Column='.$Column.'&amp;ColumnValue='.$ColumnValue.'">Celkový seznam</a>';
     183    $Output .= '<a href="?Action=ShowList&amp;Table='.$List['ItemId'].'&amp;Column='.$Column.'&amp;ColumnValue='.$ColumnValue.'">Celkový seznam</a>';
    184184  } else
    185185  {
    186     $Output .= '<a href="?Action=ShowList&amp;Table='.$List['TableName'].'">Celkový seznam</a>';
     186    $Output .= '<a href="?Action=ShowList&amp;Table='.$List['ItemId'].'">Celkový seznam</a>';
    187187  }
    188188  return($Output);
     
    203203      if($Type['BaseType'] != 'PointerOneToMany')
    204204      {
    205         $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
     205        $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['ItemId'], 'SourceItemId' => $DbRow['Id'], 'Type' => $Item['Type']);
    206206      }
    207207    }
     
    215215  );
    216216  $Form->LoadValuesFromForm();
    217   $System->Modules['DatabaseList']->EditItem($List['TableName'], $Form->Values, $Id);
     217  $System->Modules['DatabaseList']->EditItem($List['ItemId'], $Form->Values, $Id);
    218218  $NewId = $Database->insert_id;
    219219  $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Edit']);
     
    223223  $Form->Values['ItemId'] = $Id;
    224224  $Form->Values['ListTableName'] = $List['TableName'];
    225   ExecuteListEvent($List['TableName'], 'OnEdit', $Form->Values);
     225  ExecuteListEvent($List['ItemId'], 'OnEdit', $Form->Values);
    226226  return($Output);
    227227}
     
    242242      if($Item['Required'] == 1) $Required = '*'; else $Required = '';
    243243      if($Item['Editable'] == 1)
    244         $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0);
     244        $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['ItemId'], 'SourceItemId' => 0);
    245245    } else
    246246    if($Item['Name'] == $Column)
     
    262262  if(($Column != '') and ($ColumnValue != 0))
    263263  {
    264     $Output .= '<a href="?Action=ShowList&amp;Table='.$List['TableName'].'&amp;Column='.$Column.'&amp;ColumnValue='.$ColumnValue.'">Celkový seznam</a>';
     264    $Output .= '<a href="?Action=ShowList&amp;Table='.$List['ItemId'].'&amp;Column='.$Column.'&amp;ColumnValue='.$ColumnValue.'">Celkový seznam</a>';
    265265  } else
    266266  {
    267     $Output .= '<a href="?Action=ShowList&amp;Table='.$List['TableName'].'">Celkový seznam</a>';
     267    $Output .= '<a href="?Action=ShowList&amp;Table='.$List['ItemId'].'">Celkový seznam</a>';
    268268  }
    269269  return($Output);
     
    284284    {
    285285      if($Item['Required'] == 1) $Required = '*'; else $Required = '';
    286       $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['TableName'], 'SourceItemId' => 0);
     286      $DefinitionItems[] = array('Name' => $Item['Name'], 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => '', 'SourceTable' => $List['ItemId'], 'SourceItemId' => 0);
    287287    } else
    288288    if($Item['Name'] == $Column)
     
    300300  );
    301301  $Form->LoadValuesFromForm();
    302   $NewItemId = $System->Modules['DatabaseList']->AddItem($List['TableName'], $Form->Values);
     302  $NewItemId = $System->Modules['DatabaseList']->AddItem($List['ItemId'], $Form->Values);
    303303  $NewId = $Database->insert_id;
    304304  $System->Modules['Log']->Add($List['Id'], $NewId, $LogActionType['Add']);
     
    306306  $Output .= ShowViewItem($List, $NewItemId);
    307307  $Form->Values['Column'] = $_POST['Column'];
    308   ExecuteListEvent($List['TableName'], 'OnAdd', $Form->Values);
     308  ExecuteListEvent($List['ItemId'], 'OnAdd', $Form->Values);
    309309  return($Output);
    310310}
     
    326326      if($Type['BaseType'] != 'PointerOneToMany')
    327327      {
    328         $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['TableName'], 'SourceItemId' => 0);
     328        $DefinitionItems[] = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['ItemId'], 'SourceItemId' => 0);
    329329      }
    330330    }
     
    336336    );
    337337    $Output .= $Form->ShowReadOnlyForm();
    338     if(CheckPermission('Write', $List['ItemId'])) $Output .= '<a href="?Action=EditItem&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'">Editovat</a> ';
     338    if(CheckPermission('Write', $List['ItemId'])) $Output .= '<a href="?Action=EditItem&amp;Table='.$List['ItemId'].'&amp;Item='.$DbRow['ItemId'].'">Editovat</a> ';
    339339
    340340    if(($Column != '') and ($ColumnValue != 0))
    341341    {
    342       $Output .= '<a href="?Action=ShowList&amp;Table='.$List['TableName'].'&amp;Column='.$Column.'&amp;ColumnValue='.$ColumnValue.'">Celkový seznam</a>';
     342      $Output .= '<a href="?Action=ShowList&amp;Table='.$List['ItemId'].'&amp;Column='.$Column.'&amp;ColumnValue='.$ColumnValue.'">Celkový seznam</a>';
    343343    } else
    344344    {
    345       $Output .= '<a href="?Action=ShowList&amp;Table='.$List['TableName'].'">Celkový seznam</a>';
    346     }
    347     $Output .= ' <a href="?Action=ShowHistory&amp;Table='.$List['TableName'].'&amp;Item='.$DbRow['ItemId'].'">Historie</a>';
     345      $Output .= '<a href="?Action=ShowList&amp;Table='.$List['ItemId'].'">Celkový seznam</a>';
     346    }
     347    $Output .= ' <a href="?Action=ShowHistory&amp;Table='.$List['ItemId'].'&amp;Item='.$DbRow['ItemId'].'">Historie</a>';
    348348    $Output .= '<div class="line"></div>';
    349349    foreach($List['Items'] as $Index => $Item)
     
    366366  if(!CheckPermission('Write', $List['ItemId'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění'));
    367367  $System->Modules['Log']->Add($List['Id'], $Id, $LogActionType['Delete']);
    368   $System->Modules['DatabaseList']->DeleteItem($List['TableName'], $Id);
     368  $System->Modules['DatabaseList']->DeleteItem($List['ItemId'], $Id);
    369369  $Output = 'Položka smazána.';
    370   $Output .= ShowList($_SESSION['Table'], $_SESSION['Column'], $_SESSION['ColumnValue']).'<br /><br />';
    371   ExecuteListEvent($List['TableName'], 'OnDelete', $Id);
     370  $Output .= ShowList($List, $_SESSION['Column'], $_SESSION['ColumnValue']).'<br /><br />';
     371  ExecuteListEvent($List['ItemId'], 'OnDelete', $Id);
    372372  return($Output);
    373373}
     
    386386    {
    387387      if(CheckPermission('Read', $DbRow2['ItemId']))
    388         $Group .= '<a href="?Action=ShowList&amp;Table='.$DbRow2['TableName'].'">'.$DbRow2['Title'].'</a><br />';
     388        $Group .= '<a href="?Action=ShowList&amp;Table='.$DbRow2['ItemId'].'">'.$DbRow2['Title'].'</a><br />';
    389389    }
    390390    if($Group != '')
     
    411411  {
    412412    $List = GetListDefinition($_SESSION['Table']);
     413    if($List == NULL) SystemMessage('Zobrazení stránky', 'Seznam id '.$_SESSION['Table'].' nenalezen!');
     414    //echo($_SESSION['Table']);
     415    //print_r($List);
    413416    if(array_key_exists('Action', $_SESSION))
    414417    {
     
    451454  if(!array_key_exists($Id, $Lists))
    452455  {
    453     $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) AND (t1.DeletionTime IS NULL) AND t1.TableName="'.$Id.'"');
     456    $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) AND (t1.DeletionTime IS NULL) AND t1.ItemId="'.$Id.'"');
    454457    if($DbResult->num_rows > 0)
    455458    {
     
    468471       'Items' => $Items,
    469472      );
    470       if(!array_key_exists($List['TableName'], $TypeDefinitionList))
     473      //if(!array_key_exists($List['ItemId'], $TypeDefinitionList))
    471474      {
    472475        $ClassName = 'List'.$DbRow['TableName'];
    473476        if(class_exists($ClassName)) $List['Class'] = new $ClassName;
    474477      }
    475       $Lists[$List['TableName']] = $List;
    476     } else $Lists[$List['TableName']] = NULL;
     478      $Lists[$List['ItemId']] = $List;
     479    } else $Lists[$List['ItemId']] = NULL;
    477480  }
    478481  return($Lists[$Id]);
     
    491494      $DbRow = $DbResult->fetch_assoc();
    492495      $DbRow['Parameters'] = explode('|', $DbRow['Parameters']);
     496      if(($DbRow['ParentType'] == TypePointerOneToOneId) or ($DbRow['ParentType'] == TypePointerOneToManyId))
     497      {
     498        $DbResult2 = $Database->query('SELECT t1.* FROM `SystemList` AS t1 LEFT JOIN `SystemType` AS t2 ON t1.ItemId=t2.ItemId AND t1.Id < t2.Id WHERE (t2.ItemId IS NULL) AND (t1.DeletionTime IS NULL) AND t1.TableName="'.$DbRow['Parameters'][0].'"');
     499        $DbRow2 = $DbResult2->fetch_assoc();
     500        //echo($DbRow['ParentType'].'-'.$DbRow['Parameters'][0].'='.$DbRow2['ItemId'].'<br>');
     501        $DbRow['Parameters'][0] = $DbRow2['ItemId'];
     502      }
    493503      $DbRow['BaseType'] = $DbRow['Name'];
    494504
Note: See TracChangeset for help on using the changeset viewer.