Changeset 426


Ignore:
Timestamp:
Oct 10, 2012, 8:28:07 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Tlačítko zrušit u formulářů.
  • Opraveno: Chyba načítání informací o uživateli pokud neměl vazbu na Member/Customer.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/database.php

    r414 r426  
    7878  function delete($Table, $Condition)
    7979  {
    80     $this->PDO->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 
     80    $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 
    8181  }
    8282 
     
    9393    $Name = substr($Name, 1);
    9494    $Values = substr($Values, 1);
    95     $this->PDO->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
     95    $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    9696    $this->insert_id = $this->PDO->lastInsertId();
    9797  }
     
    106106    }
    107107    $Values = substr($Values, 2); 
    108     $this->PDO->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
     108    $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    109109  }
    110110 
     
    122122    $Values = substr($Values, 1);
    123123    //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br />');
    124     $this->PDO->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
     124    $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    125125    //echo($this->error().'<br>');
    126126  }
     
    128128  function charset($Charset)
    129129  {
    130     $this->PDO->query('SET NAMES "'.$Charset.'"');
     130    $this->query('SET NAMES "'.$Charset.'"');
    131131  }
    132132 
  • trunk/forms.php

    r302 r426  
    2020  {
    2121    if(!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';
    22     $Output = '<form class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock().'<div><input type="submit" value="'.$this->Definition['SubmitText'].'" /></div></form>';
     22    $Output = '<form class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock().
     23      '<div><input type="submit" value="'.$this->Definition['SubmitText'].'" /> '.
     24      '<input type="button" value="Zrušit" onclick="location.href=\'?\'"/></div></form>';
    2325    return($Output);
    2426  }
  • trunk/network/user_hosts.php

    r245 r426  
    1414    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
    1515    $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>CZFree adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>';
    16     $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = '.$this->System->Modules['User']->User['Member'].' ORDER BY NetworkDevice.Name');
     16    $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->Modules['User']->User['Id'].') ORDER BY NetworkDevice.Name');
    1717    while($Device = $DbResult->fetch_assoc())
    1818    {
  • trunk/page.php

    r323 r426  
    1717    'map' => array('',
    1818      'index.php' => 'Mapa sítě',
     19    ),
     20    'tv' => array('',
     21      'index.php' => 'Síťová televize',
    1922    ),
    2023    'network' => array('',
  • trunk/user.php

    r416 r426  
    3636  var $PermissionCache = array();
    3737  var $PermissionGroupCache = array();
     38  var $PermissionGroupCacheOp = array();
    3839
    3940  function Check()
     
    5455    if($Row['User'] != $this->AnonymousUserId)
    5556    {
    56       $Query = $this->Database->query('SELECT User.*, UserCustomerRel.Customer AS Member FROM User JOIN UserCustomerRel ON UserCustomerRel.User=User.Id WHERE User.Id='.$Row['User']);     
     57      $Query = $this->Database->query('SELECT User.*, UserCustomerRel.Customer AS Member FROM User LEFT JOIN UserCustomerRel ON UserCustomerRel.User=User.Id WHERE User.Id='.$Row['User']);     
    5758      $this->User = $Query->fetch_assoc();
    5859      $Result = USER_LOGGED;
     
    218219    }
    219220
    220 
    221221    // Check group-operation relation
    222     $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"');
    223     if($DbResult->num_rows > 0) return(true);
     222    if(array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp))
     223    {
     224      $PermissionExists = true;
     225    } else
     226    {         
     227      // If no permission combination exists in cache, do new check of database items           
     228      $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"');
     229      if($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true;
     230        else $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = false;
     231      $PermissionExists = true;
     232    }
     233    if($PermissionExists)
     234    {
     235      return($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]);
     236    }
    224237    return(false);
    225238  }
     
    227240  function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0)
    228241  {
     242    //echo('Check '.$Module.' '.$Operation.' '.$ItemType.' '.$ItemIndex);
     243    //
    229244    // First try to check cache
    230245    if(in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))
    231246    {
    232       $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache);
     247      $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemIndex), $this->PermissionCache);
    233248      $PermissionExists = is_numeric($OperationId);
    234249    } else
     
    240255        $DbRow = $DbResult->fetch_array();
    241256        $OperationId = $DbRow['Id'];
    242         $this->PermissionCache[$DbRow['Id']] = array($Module, $Operation, $ItemType, $ItemType);       
     257        $this->PermissionCache[$DbRow['Id']] = array($Module, $Operation, $ItemType, $ItemIndex);
    243258        $PermissionExists = true;
    244259      } else
    245260      {         
    246         $this->PermissionCache[$DbRow['Id'].'_'] = array($Module, $Operation, $ItemType, $ItemType);       
     261        $this->PermissionCache[$DbRow['Id'].'_'] = array($Module, $Operation, $ItemType, $ItemIndex);       
    247262        $PermissionExists = false;
    248263      }
Note: See TracChangeset for help on using the changeset viewer.