Changeset 584


Ignore:
Timestamp:
Oct 31, 2013, 4:57:11 PM (11 years ago)
Author:
chronos
Message:
  • Přidáno: Kontrola oprávnění při zobrazení informačního systému.
  • Přidáno: Tabulka Module pro seznam existujících modulů.
  • Upraveno: PermissionOperation se nyní odkazuje na id modulu.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Version.php

    r583 r584  
    11<?php
    22
    3 $Revision = 582; // Subversion revision
    4 $DatabaseRevision = 574; // SQL structure revision
    5 $ReleaseTime = '2013-10-19';
     3$Revision = 584; // Subversion revision
     4$DatabaseRevision = 544; // SQL structure revision
     5$ReleaseTime = '2013-10-31';
  • trunk/FormClasses.php

    r568 r584  
    1919{
    2020  $FormManager->Classes = array(
     21  'Module' => array(
     22    'Title' => 'Moduly',
     23    'Table' => 'Module',
     24    'Items' => array(
     25      'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''),
     26      'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
     27    ),
     28  ),
    2129  'Action' => array(
    2230    'Title' => 'Akce',
     
    239247    'Filter' => '1',
    240248  ),
     249  'TModule' => array(
     250    'Type' => 'Reference',
     251    'Table' => 'Module',
     252    'Id' => 'Id',
     253    'Name' => 'Name',
     254    'Filter' => '1',
     255  ),
    241256  'TMapPosition' => array(
    242257    'Type' => 'Reference',
  • trunk/Modules/IS/IS.php

    r581 r584  
    7575  {
    7676    $Output = '';
     77    if(!$this->System->User->CheckPermission($Table, 'Write'))
     78      return('Nemáte oprávnění');
    7779    if(array_key_exists('o', $_GET))
    7880    {
     
    123125  {
    124126    $Output = '';
     127    if(!$this->System->User->CheckPermission($Table, 'Write'))
     128      return('Nemáte oprávnění');
    125129    $this->Database->delete($Table, 'Id='.$Id);
    126130    $Output .= $this->SystemMessage('Odstranění položky', 'Položka odstraněna');
     
    132136  {
    133137    $Output = '';
     138    if(!$this->System->User->CheckPermission($Table, 'Write'))
     139      return('Nemáte oprávnění');
    134140    if(array_key_exists('o', $_GET))
    135141    {
     
    182188    if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table];
    183189      else return($this->SystemMessage('Chyba', 'Tabulka nenalezena'));
     190    if(!$this->System->User->CheckPermission($Table, 'Read'))
     191      return('Nemáte oprávnění');
    184192   
    185193    $Form = new Form($this->System->FormManager);
     
    383391  function ShowSelect($Table, $Filter = '', $Title = '')
    384392  {
     393    if(!$this->System->User->CheckPermission($Table, 'Read'))
     394      return('Nemáte oprávnění');
    385395    $this->BasicHTML = true;
    386396    $this->HideMenu = true;
     
    394404  function ShowMapSelect($Table, $Filter = '', $Title = '')
    395405  {
     406    if(!$this->System->User->CheckPermission($Table, 'Write'))
     407      return('Nemáte oprávnění');
    396408    $MapApi = new MapApiGoogle($this->System);
    397409    $MapApi->Position = array('Lat' => $this->System->Config['Map']['DefaultLatitude'],
     
    407419  function ShowList($Table, $Filter = '', $Title = '', $ExcludeColumn = '') 
    408420  {
     421    if(!$this->System->User->CheckPermission($Table, 'Read'))
     422      return('Nemáte oprávnění');
    409423    $RowActions = '<a href="?a=view&amp;t='.$Table.'&amp;i=#RowId"><img alt="Ukázat" title="Ukázat" src="'.
    410424      $this->System->Link('/images/view.png').'"/></a>'.
     
    521535        'Items' => array('Type' => 'TMenuItemListMenu', 'Caption' => 'Položky'),
    522536      ),
    523     ));
    524    
     537    ));   
    525538  } 
    526539 
  • trunk/Modules/NetworkConfigLinux/Generators/DNS.php

    r569 r584  
    117117  'Host' => array(),
    118118  'Alias' => array(),
    119   'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68', '10.145.69', '10.145.70', '10.145.71', '77.92.221', '172.16.0', '172.16.1'),
     119  'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67',
     120    '10.145.68', '10.145.69', '10.145.70', '10.145.71', '77.92.221', '172.16.0',
     121    '172.16.1'),
    120122);
    121123
  • trunk/Modules/NetworkShare/SharePage.php

    r548 r584  
    6868  function Show()
    6969  {
    70     if(!$this->System->User->CheckPermission('Share', 'Display')) return('Nemáte oprávnění');
     70    if(!$this->System->User->CheckPermission('NetworkShare', 'Display')) return('Nemáte oprávnění');
    7171
    7272    // If not only online checkbox checked
  • trunk/Modules/OpeningHours/OpeningHours.php

    r548 r584  
    3636  function EditSubject($Id)
    3737  {
    38     if($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
     38    if($this->System->User->CheckPermission('OpeningHours', 'Edit'))
    3939    {
    4040      $Output = '<div class="Centred">';
     
    7878   
    7979    $Output = '';
    80     if($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
     80    if($this->System->User->CheckPermission('OpeningHours', 'Edit'))
    8181    {
    8282      $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id);
  • trunk/Modules/Portal/Portal.php

    r581 r584  
    105105  {
    106106    $Output = '';
    107     $DbResult = $this->Database->query('SELECT *, `ActionIcon`.`Name` AS `Icon` FROM `Action` LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
     107    $DbResult = $this->Database->query('SELECT *, `ActionIcon`.`Name` AS `Icon` FROM `Action` '.
     108      'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
    108109      'WHERE (`Group`='.$ActionGroup['Id'].') AND (`Enable` = 1)');
    109110    while($Action = $DbResult->fetch_assoc())
     
    111112      if($Action['Icon'] == '') $Action['Icon'] = 'clear.png';
    112113        if(substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = $this->System->Link($Action['URL']);
    113         if(($Action['PermissionModule'] == '') or (($Action['PermissionModule'] != '') and $this->System->User->User->CheckPermission($Action['PermissionModule'], $Action['PermissionOperation'])))       
    114         $Output .= '<img alt="'.$Action['Title'].'" src="images/favicons/'.$Action['Icon'].'" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a><br />';
     114        if($Action['PermissionOperation'] != '')
     115        {
     116          $DbResult2 = $this->Database->query('SELECT * FROM PermissionOperation'.
     117            ' LEFT JOIN Module ON Module.Id=PermissionOperation.Module'.
     118            ' WHERE Id='.$Action['PermissionOperation']);
     119          $DbRow2 = $DbResult2->fetch_assoc();
     120          if($this->System->User->User->CheckPermission($DbRow2['Module'], $DbRow2['Operation']))
     121            $Allowed = true; else $Allowed = false;       
     122        } else $Allowed = true;
     123        if($Allowed)
     124          $Output .= '<img alt="'.$Action['Title'].'" src="images/favicons/'.$Action['Icon'].'" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a><br />';
    115125    }
    116126    return($this->Panel($ActionGroup['Name'], $Output));
  • trunk/Modules/User/User.php

    r565 r584  
    290290  function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0)
    291291  {
     292    // Get module id
     293    $DbResult = $this->Database->select('Module', 'Id', '`Name`="'.$Module.'"');
     294    if($DbResult->num_rows > 0)
     295    {
     296      $DbRow = $DbResult->fetch_assoc();
     297      $ModuleId = $DbRow['Id'];
     298    } else return(false);
     299   
    292300    // First try to check cache
    293301    if(in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))
     
    298306    {   
    299307      // If no permission combination exists in cache, do new check of database items
    300       $DbResult = $this->Database->select('PermissionOperation', 'Id', '`Module`="'.$Module.'" AND `Item`="'.$ItemType.'" AND `ItemId`='.$ItemIndex.' AND `Operation`="'.$Operation.'"');
     308      $DbResult = $this->Database->select('PermissionOperation', 'Id', '`Module`="'.$ModuleId.'" AND `Item`="'.$ItemType.'" AND `ItemId`='.$ItemIndex.' AND `Operation`="'.$Operation.'"');
    301309      if($DbResult->num_rows > 0)
    302310      {
     
    456464      'Table' => 'PermissionOperation',
    457465      'Items' => array(
    458         'Module' => array('Type' => 'String', 'Caption' => 'Modul', 'Default' => ''),
     466        'Module' => array('Type' => 'TModule', 'Caption' => 'Modul', 'Default' => ''),
    459467        'Operation' => array('Type' => 'String', 'Caption' => 'Operace', 'Default' => ''),
    460468        'Item' => array('Type' => 'String', 'Caption' => 'Položka', 'Default' => ''),
  • trunk/admin/Updates.php

    r574 r584  
    383383}
    384384
     385function UpdateTo584($Manager)
     386{
     387  $Manager->Execute("CREATE TABLE IF NOT EXISTS `Module` (
     388      `Id` int(11) NOT NULL AUTO_INCREMENT,
     389      `Name` varchar(255) NOT NULL,
     390      `Title` varchar(255) NOT NULL,
     391      PRIMARY KEY (`Id`)
     392  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=33 ;");
     393 
     394  $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`) VALUES
     395  (1, 'Customer', 'Zákazník'),
     396  (2, 'EmailQueue', 'Fronta emailů'),
     397  (3, 'Error', 'Obsluha chyb'),
     398  (4, 'File', 'Správa souborů'),
     399  (5, 'Finance', 'Finance'),
     400  (6, 'FinanceBankAPI', 'Rozhraní pro bankovní účty'),
     401  (7, 'Chat', 'Pokec'),
     402  (8, 'IS', 'Informační systém'),
     403  (9, 'Log', 'Záznam událostí'),
     404  (10, 'Map', 'Mapa'),
     405  (11, 'Meals', 'Jídelníček'),
     406  (12, 'Meteostation', 'Meteostanice'),
     407  (13, 'Network', 'Síť'),
     408  (14, 'NetworkConfig', 'Nastavení sítě'),
     409  (15, 'NetworkConfigLinux', 'Nastavení linuxových zařízení'),
     410  (16, 'NetworkConfigRouterOS', 'Nastavení RouterOS zařízení'),
     411  (17, 'NetworkShare', 'Síťové sdílení'),
     412  (18, 'NetworkTopology', 'Síťová topologie'),
     413  (19, 'News', 'Aktuality'),
     414  (20, 'OpeningHours', 'Otvírací doby'),
     415  (21, 'Portal', 'Portál'),
     416  (22, 'Search', 'Vyhledávání'),
     417  (23, 'Setup', 'Instalace systému'),
     418  (24, 'SpeedTest', 'Měření rychlosti'),
     419  (25, 'Stock', 'Sklad'),
     420  (26, 'System', 'Systém'),
     421  (27, 'Task', 'Úlohy'),
     422  (28, 'TimeMeasure', 'Časové průběhy'),
     423  (29, 'TV', 'Televize'),
     424  (30, 'User', 'Uživatelé'),
     425  (31, 'WebCam', 'Web kamery'),
     426  (32, 'Wiki', 'Wiki');");
     427  $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'Meals' WHERE `PermissionOperation`.`Module` ='EatingPlace';");
     428  $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'NetworkShare' WHERE `PermissionOperation`.`Module` ='Share';");
     429  $Manager->Execute("UPDATE `PermissionOperation` SET `Module` = 'SubjectOpenTime' WHERE `PermissionOperation`.`Module` ='OpeningHours';");
     430  $Manager->Execute("UPDATE `PermissionOperation` SET `Module`=(SELECT `Id` FROM `Module` WHERE `Module`.`Name` = `PermissionOperation`.`Module`)");
     431  $Manager->Execute("ALTER TABLE `PermissionOperation` CHANGE `Module` `Module` INT( 11 ) NOT NULL ;");
     432  $Manager->Execute("ALTER TABLE `PermissionOperation` ADD FOREIGN KEY ( `Module` ) REFERENCES `Module` (
     433`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
     434  $Manager->Execute("UPDATE `Action` SET `Action`.`PermissionOperation` =(SELECT Id FROM `PermissionOperation` WHERE `PermissionOperation`.`Operation`=`Action`.`PermissionOperation` AND `PermissionOperation`.`Module` = (SELECT Id FROM `Module` WHERE `Module`.`Name`=`Action`.`PermissionModule`))");
     435  $Manager->Execute("ALTER TABLE `Action` CHANGE `PermissionOperation` `PermissionOperation` INT( 11 ) NULL ;");
     436  $Manager->Execute("ALTER TABLE `Action` DROP `PermissionModule` ;");
     437  $Manager->Execute("UPDATE `Action` SET `PermissionOperation`=NULL WHERE `PermissionOperation`=0");
     438  $Manager->Execute("ALTER TABLE `Action` ADD INDEX (`PermissionOperation`);");
     439  $Manager->Execute("ALTER TABLE `Action` ADD FOREIGN KEY ( `PermissionOperation` ) REFERENCES `PermissionOperation` (
     440`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
     441}
     442
     443
    385444$Updates = array(
    386445  491 => array('Revision' => 493, 'Function' => 'UpdateTo493'),
     
    405464  565 => array('Revision' => 571, 'Function' => 'UpdateTo571'),
    406465  571 => array('Revision' => 574, 'Function' => 'UpdateTo574'),
     466  574 => array('Revision' => 584, 'Function' => 'UpdateTo584'),
    407467);
Note: See TracChangeset for help on using the changeset viewer.