Changeset 900


Ignore:
Timestamp:
Feb 17, 2021, 5:15:29 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Insert sample data action partially implemented.
Location:
trunk
Files:
11 edited

Legend:

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

    r899 r900  
    66  {
    77    parent::__construct($System);
    8     $this->Name = 'Desc';
     8    $this->Name = 'Config';
    99    $this->Version = '1.0';
    1010    $this->Creator = 'Chronos';
  • trunk/Modules/Finance/Finance.php

    r899 r900  
    267267      'Table' => 'FinanceTreasuryCheck',
    268268      'DefaultSortColumn' => 'Time',
     269      'DefaultSortOrder' => 1,
    269270      'Items' => array(
    270271        'Treasury' => array('Type' => 'TFinanceTreasury', 'Caption' => 'Pokladna', 'Default' => ''),
  • trunk/Modules/Portal/Portal.php

    r899 r900  
    1717  }
    1818
    19   function DoInstall(): void
    20   {
    21    /* $this->Database->query("INSERT INTO `PanelColumn` (`Id`, `Width`) VALUES
    22     (1, ''),
    23     (2, ''),
    24     (3, '70%');");
    25     $this->Database->query("INSERT INTO `Panel` (`Id`, `Module`, `Parameters`, `Order`, `PanelColumn`) VALUES
    26     (1, 'ActionGroup', 1, 2, 1),
    27     (2, 'ActionGroup', 4, 1, 2),
    28     (3, 'ActionGroup', 5, 2, 2),
    29     (4, 'ActionGroup', 6, 3, 2),
    30     (5, 'ActionGroup', 2, 4, 2),
    31     (6, 'ActionGroup', 3, 5, 2),
    32     (7, 'NewsGroupList', '', 2, 3),
    33     (8, 'Webcam', '', 3, 1),
    34     (9, 'UserOptions', '', 1, 3),
    35     (10, 'ActionGroup', 9, 1, 1),
    36     (11, 'Meteo', '', 4, 1);");*/
     19  function DoInsertSampleData(): void
     20  {
     21    $ActionGroup1 = $this->Database->insert('ActionGroup', array('Name' => 'Síť'));
     22    $ActionGroup2 = $this->Database->insert('ActionGroup', array('Name' => 'Místní organizace'));
     23    $ActionGroup3 = $this->Database->insert('ActionGroup', array('Name' => 'Stránky občanů'));
     24    $ActionGroup4 = $this->Database->insert('ActionGroup', array('Name' => 'Vyhledávání'));
     25    $ActionGroup5 = $this->Database->insert('ActionGroup', array('Name' => 'Užitečné'));
     26    $ActionGroup6 = $this->Database->insert('ActionGroup', array('Name' => 'Zábava'));
     27    $ActionGroup7 = $this->Database->insert('ActionGroup', array('Name' => 'Hostované stránky'));
     28    $ActionGroup8 = $this->Database->insert('ActionGroup', array('Name' => 'Prodej počítačů'));
     29    $ActionGroup9 = $this->Database->insert('ActionGroup', array('Name' => 'Různé'));
     30
     31    $PanelColumn1 = $this->Database->insert('PanelColumn', array('Width' => ''));
     32    $PanelColumn2 = $this->Database->insert('PanelColumn', array('Width' => ''));
     33    $PanelColumn3 = $this->Database->insert('PanelColumn', array('Width' => '70%'));
     34
     35    $this->Database->insert('Panel', array('Module' => 'ActionGroup', 'Parameters' => $ActionGroup1, 'Order' => 2, 'PanelColumn' => $PanelColumn1));
     36    $this->Database->insert('Panel', array('Module' => 'ActionGroup', 'Parameters' => $ActionGroup4, 'Order' => 1, 'PanelColumn' => $PanelColumn2));
     37    $this->Database->insert('Panel', array('Module' => 'ActionGroup', 'Parameters' => $ActionGroup5, 'Order' => 2, 'PanelColumn' => $PanelColumn2));
     38    $this->Database->insert('Panel', array('Module' => 'ActionGroup', 'Parameters' => $ActionGroup6, 'Order' => 3, 'PanelColumn' => $PanelColumn2));
     39    $this->Database->insert('Panel', array('Module' => 'ActionGroup', 'Parameters' => $ActionGroup2, 'Order' => 4, 'PanelColumn' => $PanelColumn2));
     40    $this->Database->insert('Panel', array('Module' => 'ActionGroup', 'Parameters' => $ActionGroup3, 'Order' => 5, 'PanelColumn' => $PanelColumn2));
     41    $this->Database->insert('Panel', array('Module' => 'NewsGroupList', 'Parameters' => '', 'Order' => 2, 'PanelColumn' => $PanelColumn3));
     42    $this->Database->insert('Panel', array('Module' => 'Webcam', 'Parameters' => '', 'Order' => 3, 'PanelColumn' => $PanelColumn1));
     43    $this->Database->insert('Panel', array('Module' => 'UserOptions', 'Parameters' => '', 'Order' => 1, 'PanelColumn' => $PanelColumn3));
     44    $this->Database->insert('Panel', array('Module' => 'ActionGroup', 'Parameters' => $ActionGroup9, 'Order' => 1, 'PanelColumn' => $PanelColumn1));
     45    $this->Database->insert('Panel', array('Module' => 'Meteo', 'Parameters' => '', 'Order' => 4, 'PanelColumn' => $PanelColumn1));
    3746  }
    3847
     
    297306    $Output = '';
    298307    $DbResult = $this->Database->query('SELECT * FROM `ActionGroup`');
     308    $ActionGroups = array();
    299309    while ($DbRow = $DbResult->fetch_assoc())
    300310      $ActionGroups[$DbRow['Id']] = $DbRow;
  • trunk/Modules/System/System.php

    r899 r900  
    1616    $this->Description = 'Base system module';
    1717    $this->Type = ModuleType::System;
     18    $this->Dependencies = array(ModuleModuleManager::GetName());
    1819    $this->Models = array(UnitOfMeasure::GetClassName(), ActionIcon::GetClassName(), ActionGroup::GetClassName(),
    1920      ActionType::GetClassName(), Action::GetClassName(), Language::GetClassName(), Country::GetClassName());
  • trunk/Modules/User/User.php

    r899 r900  
    2727  function DoInstall(): void
    2828  {
    29     $this->Database->insert('PermissionGroup', array('Id' => 1, 'Description' => 'Ostatní'));
    30     $this->Database->insert('PermissionGroup', array('Id' => 2, 'Description' => 'Registrovaní uživatelé'));
    31     $this->Database->insert('PermissionGroup', array('Id' => 3, 'Description' => 'Zákazníci'));
    32     $this->Database->insert('PermissionGroup', array('Id' => 4, 'Description' => 'Správci sítě'));
    33     $this->Database->insert('PermissionGroup', array('Id' => 5, 'Description' => 'Systémoví správci'));
     29  }
     30
     31  function DoInsertSampleData(): void
     32  {
     33    $DbResult = $this->Database->select('User', 'Id', 'Login="admin"');
     34    if ($DbResult->num_rows == 0)
     35    {
     36      $UserId = $this->Database->insert('User', array('Id' => 1, 'Login' => 'admin', 'Name' => 'Admin', 'Password' => 'd04b7c77a814de3207315c2f82dcd97a90ed33ca',
     37        'Salt' => 'd5d8eb61e1a20d98b45b415ccd2fae802cb41294', 'Email' => 'admin@localhost', 'LastIpAddress' => null, 'LastLoginTime' => null,
     38        'RegistrationTime' => '2021-02-17 14:56:22', 'Locked' => 0, 'InitPassword' => null));
     39
     40      $PermissionGroup1 = $this->Database->insert('PermissionGroup', array('Description' => 'Ostatní'));
     41      $PermissionGroup2 = $this->Database->insert('PermissionGroup', array('Description' => 'Registrovaní uživatelé'));
     42      $PermissionGroup3 = $this->Database->insert('PermissionGroup', array('Description' => 'Zákazníci'));
     43      $PermissionGroup4 = $this->Database->insert('PermissionGroup', array('Description' => 'Správci sítě'));
     44      $PermissionGroup5 = $this->Database->insert('PermissionGroup', array('Description' => 'Systémoví správci'));
     45
     46      $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'AssignedGroup' => $PermissionGroup5));
     47    }
    3448  }
    3549
  • trunk/Modules/User/UserModel.php

    r899 r900  
    505505  {
    506506    $Desc = new ModelDesc(self::GetClassName());
    507     //$Desc->AddReference('Module', Module::GetClassName());
     507    $Desc->AddReference('Module', Module::GetClassName());
    508508    $Desc->AddString('Operation');
    509509    $Desc->AddString('Item');
  • trunk/Packages/Common/Database.php

    r898 r900  
    134134  }
    135135
    136   function insert(string $Table, array $Data): void
     136  function insert(string $Table, array $Data): int
    137137  {
    138138    $this->query($this->GetInsert($Table, $Data));
    139139    $this->insert_id = $this->PDO->lastInsertId();
     140    return $this->insert_id;
    140141  }
    141142
  • trunk/Packages/Common/Module.php

    r899 r900  
    1717  const Enable = 5;
    1818  const Disable = 6;
     19  const InsertSampleData = 7;
    1920}
    2021
     
    141142  }
    142143
     144  function InsertSampleData(): void
     145  {
     146    $this->DoInsertSampleData();
     147  }
     148
    143149  function Reinstall(): void
    144150  {
     
    224230  }
    225231
     232  protected function DoInsertSampleData(): void
     233  {
     234  }
     235
    226236  function AddModel(Model $Model): void
    227237  {
  • trunk/Packages/Common/ModuleManager.php

    r899 r900  
    5757          if ($Action == ModuleAction::Disable) $Module->Disable();
    5858          if ($Action == ModuleAction::Upgrade) $Module->Upgrade();
     59          if ($Action == ModuleAction::InsertSampleData) $Module->InsertSampleData();
    5960        }
    6061      }
     
    227228  function RegisterModule(Module $Module): void
    228229  {
     230    if (array_key_exists($Module->Name, $this->Modules))
     231      die('Can\'t register module '.$Module->Name.' because it already exists.');
    229232    $this->Modules[$Module->Name] = &$Module;
    230233    $Module->Manager = &$this;
  • trunk/Packages/Common/Modules/ModuleManager.php

    r899 r900  
    260260      $ModelId = $DbRow['Id'];
    261261      $DbResult = $this->Database->delete('ModelField', '(Model='.$ModelId.')');
    262     }
    263     $this->Database->delete('Model', '(Id='.$ModelId.')');
     262      $this->Database->delete('Model', '(Id='.$ModelId.')');
     263    } else echo('Can\'t remove model '.$ModelDesc->Name.'<br/>');
    264264    $this->RemoveModelDatabase($ModelDesc);
    265265  }
  • trunk/Packages/Common/Modules/Setup.php

    r899 r900  
    5959    $Output = $this->UpdateManager->Upgrade();
    6060    return $Output;
    61   }
    62 
    63   function InsertSampleData(): void
    64   {
    6561  }
    6662}
     
    8177    $this->FullTitle = T('Application setup');
    8278    $this->ShortTitle = T('Application setup');
    83     //$this->ParentClass = 'PagePortal';
     79    //$this->ParentClass = 'PageSetupRedirect';
    8480    $this->ConfigDir = dirname(dirname(dirname(__FILE__))).'/Config';
    8581    $this->YesNo = array(false => T('No'), true => T('Yes'));
     
    212208        {
    213209          $Output .= '<h3>Vložení vzorových dat</h3>';
    214           ModuleSetup::Cast($this->System->GetModule('Setup'))->InsertSampleData();
     210          $this->System->ModuleManager->Perform(array(ModuleAction::InsertSampleData), array(ModuleCondition::Installed));
    215211          $Output .= $this->ControlPanel();
    216212        }
Note: See TracChangeset for help on using the changeset viewer.