Ignore:
Timestamp:
Oct 31, 2013, 8:57:41 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: V modulu IS se oprávnění kontroluje nyní pomocí názvů modulů ísto chybného jména tabulky.
File:
1 edited

Legend:

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

    r584 r585  
    88  var $ShortTitle = 'Správa dat';
    99  var $ParentClass = 'PagePortal';
    10   var $MenuItems = array();
    11   var $MenuItemsLoaded = false;
     10  var $MenuItems;
    1211  var $HideMenu = false;
    1312
     
    3635    {
    3736      $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">';
    38       $Output .= '<strong>Nabídka:</strong>'.$this->ShowMenuItem('');
     37      $Output .= '<strong>Nabídka:</strong>'.$this->ShowMenu();
    3938      $Output .= '</td><td style="width: 80%; vertical-align: top;">';
    4039      $Output .= $Content;
     
    7574  {
    7675    $Output = '';
    77     if(!$this->System->User->CheckPermission($Table, 'Write'))
     76    if(!$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    7877      return('Nemáte oprávnění');
    7978    if(array_key_exists('o', $_GET))
     
    125124  {
    126125    $Output = '';
    127     if(!$this->System->User->CheckPermission($Table, 'Write'))
     126    if(!$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    128127      return('Nemáte oprávnění');
    129128    $this->Database->delete($Table, 'Id='.$Id);
     
    136135  {
    137136    $Output = '';
    138     if(!$this->System->User->CheckPermission($Table, 'Write'))
     137    if(!$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    139138      return('Nemáte oprávnění');
    140139    if(array_key_exists('o', $_GET))
     
    188187    if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
    189188      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
    190     if(!$this->System->User->CheckPermission($Table, 'Read'))
     189    if(!$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
    191190      return('Nemáte oprávnění');
    192191   
     
    391390  function ShowSelect($Table, $Filter = '', $Title = '')
    392391  {
    393     if(!$this->System->User->CheckPermission($Table, 'Read'))
     392    if(!$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
    394393      return('Nemáte oprávnění');
    395394    $this->BasicHTML = true;
     
    404403  function ShowMapSelect($Table, $Filter = '', $Title = '')
    405404  {
    406     if(!$this->System->User->CheckPermission($Table, 'Write'))
     405    if(!$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
    407406      return('Nemáte oprávnění');
    408407    $MapApi = new MapApiGoogle($this->System);
     
    419418  function ShowList($Table, $Filter = '', $Title = '', $ExcludeColumn = '') 
    420419  {
    421     if(!$this->System->User->CheckPermission($Table, 'Read'))
     420    if(!$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
    422421      return('Nemáte oprávnění');
    423422    $RowActions = '<a href="?a=view&amp;t='.$Table.'&amp;i=#RowId"><img alt="Ukázat" title="Ukázat" src="'.
     
    457456  }
    458457 
     458  function ShowMenu()
     459  {
     460    $this->MenuItems = array();
     461    $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName`, `Action`.`PermissionOperation` AS `Permission` FROM `MenuItem` '.
     462      'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
     463      'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
     464      'WHERE `MenuItem`.`Menu`=1 '.
     465      'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
     466    while($DbRow = $DbResult->fetch_assoc())
     467    {
     468      //if($DbRow['Permission'] != '')
     469      $this->MenuItems[$DbRow['Id']] = $DbRow;
     470    }
     471    return($this->ShowMenuItem(''));
     472  }
     473 
    459474  function ShowMenuItem($Parent)
    460475  {
    461     if($this->MenuItemsLoaded == false)
    462     {
    463       $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName`  FROM `MenuItem` '.
    464         'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
    465         'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
    466         'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
    467       while($DbRow = $DbResult->fetch_assoc())
    468       {
    469         $this->MenuItems[$DbRow['Id']] = $DbRow;
    470       }
    471       $this->MenuItemsLoaded = true;
    472     }   
    473    
    474476    $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">';
    475477    foreach($this->MenuItems as $MenuItem)
     
    489491    $Output .= '</ul>';
    490492    return($Output);
     493  }
     494 
     495  function TableToModule($Table)
     496  {
     497    $DbResult = $this->Database->query('SELECT (SELECT Name FROM Module WHERE Module.Id=Model.Module) AS Name FROM Model WHERE Name="'.$Table.'"');
     498    if($DbResult->num_rows == 1)
     499    {
     500      $DbRow = $DbResult->fetch_assoc();
     501      return($DbRow['Name']);     
     502    } else return('');
    491503  }
    492504}
Note: See TracChangeset for help on using the changeset viewer.