Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

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

    r825 r873  
    3939
    4040    $DbResult = $this->Database->query($Query);
    41     while($Module = $DbResult->fetch_assoc())
    42     {
    43       if($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies'];
     41    while ($Module = $DbResult->fetch_assoc())
     42    {
     43      if ($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies'];
    4444      else $Dependencies = ' ';
    45       if($Module['Installed'] == 1) $Installed = 'Ano';
     45      if ($Module['Installed'] == 1) $Installed = 'Ano';
    4646      else $Installed = 'Ne';
    47       if($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&amp;Id='.$Module['Id'].'">Odinstalovat</a>';
     47      if ($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&amp;Id='.$Module['Id'].'">Odinstalovat</a>';
    4848      else $Actions = '<a href="?A=Install&amp;Id='.$Module['Id'].'">Instalovat</a>';
    4949      $Output .= '<tr><td>'.$Module['Name'].'</td>'.
     
    5959    $Output .= $PageList['Output'];
    6060    $Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';
    61     return($Output);
     61    return ($Output);
    6262  }
    6363
     
    6565  {
    6666    $Output = '';
    67     if(array_key_exists('A', $_GET))
    68     {
    69       if($_GET['A'] == 'SaveToDb')
     67    if (array_key_exists('A', $_GET))
     68    {
     69      if ($_GET['A'] == 'SaveToDb')
    7070      {
    7171        $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase();
    7272        $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován');
    7373      } else
    74       if($_GET['A'] == 'Install')
     74      if ($_GET['A'] == 'Install')
    7575      {
    7676        $this->System->ModuleManager->LoadModules(false);
    7777        $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']);
    78         if($ModuleName != '')
     78        if ($ModuleName != '')
    7979        {
    8080          $this->System->Modules[$ModuleName]->Install();
     
    8383
    8484      } else
    85       if($_GET['A'] == 'Uninstall')
     85      if ($_GET['A'] == 'Uninstall')
    8686      {
    8787        $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']);
    88         if($ModuleName != '')
     88        if ($ModuleName != '')
    8989        {
    9090          $this->System->ModuleManager->Modules[$ModuleName]->UnInstall();
     
    9494    }
    9595    $Output .= $this->ShowList();
    96     return($Output);
     96    return ($Output);
    9797  }
    9898}
     
    408408  function IsInstalled()
    409409  {
    410     if($this->InstalledChecked == false)
     410    if ($this->InstalledChecked == false)
    411411    {
    412412      $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables
    413413WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";');
    414       if($DbResult->num_rows > 0) $this->Installed = true;
     414      if ($DbResult->num_rows > 0) $this->Installed = true;
    415415        else $this->Installed = false;
    416416      $this->InstalledChecked = true;
    417417    }
    418     return($this->Installed);
     418    return ($this->Installed);
    419419  }
    420420
    421421  function ModuleChange($Module)
    422422  {
    423     //if($this->IsInstalled())
    424     {
    425 
    426       if($Module->IsInstalled()) $Installed = 1;
     423    //if ($this->IsInstalled())
     424    {
     425
     426      if ($Module->IsInstalled()) $Installed = 1;
    427427        else $Installed = 0;
    428428      $this->Database->query('UPDATE `Module` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"');
     
    436436    $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`';
    437437    $DbResult = $this->Database->query($Query);
    438     while($Module = $DbResult->fetch_array())
     438    while ($Module = $DbResult->fetch_array())
    439439    {
    440440      //echo($Module['Name'].',');
     
    453453    $Modules = array();
    454454    $DbResult = $this->Database->query('SELECT * FROM `Module`');
    455     while($DbRow = $DbResult->fetch_assoc())
     455    while ($DbRow = $DbResult->fetch_assoc())
    456456    {
    457457      $Modules[$DbRow['Name']] = $DbRow;
    458       if($this->System->ModuleManager->ModulePresent($DbRow['Name']))
     458      if ($this->System->ModuleManager->ModulePresent($DbRow['Name']))
    459459        $this->System->ModuleManager->Modules[$DbRow['Name']]->Id = $DbRow['Id'];
    460460    }
    461461
    462462    // Add missing
    463     foreach($this->System->ModuleManager->Modules as $Module)
    464     {
    465       if(!array_key_exists($Module->Name, $Modules))
     463    foreach ($this->System->ModuleManager->Modules as $Module)
     464    {
     465      if (!array_key_exists($Module->Name, $Modules))
    466466      {
    467467        $this->Database->insert('Module', array('Name' => $Module->Name,
     
    480480
    481481    // Remove exceeding
    482     foreach($Modules as $Module)
    483     if(!$this->System->ModuleManager->ModulePresent($Module['Name']))
     482    foreach ($Modules as $Module)
     483    if (!$this->System->ModuleManager->ModulePresent($Module['Name']))
    484484    {
    485485      $Output .= 'Removing module '.$Module['Name'].' from list</br/>';
     
    487487      $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']);
    488488      $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']);
    489       while($DbRow = $DbResult->fetch_assoc())
     489      while ($DbRow = $DbResult->fetch_assoc())
    490490      {
    491491        $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']);
     
    495495      $this->Database->query('DELETE FROM `Model` WHERE `Module` = '.$Module['Id']);
    496496      $DbResult = $this->Database->query('SELECT Id FROM `Model` WHERE `Module` = '.$Module['Id']);
    497       while($DbRow = $DbResult->fetch_assoc())
     497      while ($DbRow = $DbResult->fetch_assoc())
    498498        $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']);
    499499      $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']);
     
    503503    $DbDependency = array();
    504504    $DbResult = $this->Database->query('SELECT * FROM `ModuleLink`');
    505     while($DbRow = $DbResult->fetch_assoc())
     505    while ($DbRow = $DbResult->fetch_assoc())
    506506      $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule'];
    507507
    508     foreach($this->System->ModuleManager->Modules as $Module)
     508    foreach ($this->System->ModuleManager->Modules as $Module)
    509509    {
    510510      // Add missing
    511       foreach($Module->Dependencies as $Dependency)
    512       {
    513         if(!array_key_exists($Module->Id, $DbDependency) or
     511      foreach ($Module->Dependencies as $Dependency)
     512      {
     513        if (!array_key_exists($Module->Id, $DbDependency) or
    514514        !in_array($this->System->ModuleManager->Modules[$Dependency]->Id, $DbDependency[$Module->Id]))
    515515        {
    516           if(array_key_exists($Dependency, $this->System->ModuleManager->Modules))
     516          if (array_key_exists($Dependency, $this->System->ModuleManager->Modules))
    517517            $DependencyId = $this->System->ModuleManager->Modules[$Dependency]->Id;
    518518            else throw new Exception('Dependent module '.$Dependency.' not found');
     
    523523
    524524      // Remove exceeding
    525       if(array_key_exists($Module->Id, $DbDependency))
    526       foreach($DbDependency[$Module->Id] as $Dep)
     525      if (array_key_exists($Module->Id, $DbDependency))
     526      foreach ($DbDependency[$Module->Id] as $Dep)
    527527      {
    528528        $DepModName = $this->System->ModuleManager->SearchModuleById($Dep);
    529         if(!in_array($DepModName, $Module->Dependencies))
     529        if (!in_array($DepModName, $Module->Dependencies))
    530530        $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '.
    531531          $Module->Id.' AND LinkedModule='.$Dep);
    532532      }
    533533    }
    534     return($Output);
     534    return ($Output);
    535535  }
    536536}
Note: See TracChangeset for help on using the changeset viewer.