Changeset 934 for trunk


Ignore:
Timestamp:
May 11, 2022, 10:07:18 PM (3 years ago)
Author:
chronos
Message:
  • Added: System names for Permission groups.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UpdateTrace.php

    r921 r934  
    22072207        "VALUES (NULL , 'Fyzické adresy', ".$DbRow['Id'].", '".$ActionId."', '1');");
    22082208  }
     2209}
     2210
     2211function UpdateTo933(UpdateManager $Manager): void
     2212{
     2213  $Manager->Execute('ALTER TABLE `PermissionGroup` ADD `SysName` VARCHAR(255) NULL DEFAULT "" AFTER `Description`;');
     2214  $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="admins" WHERE `Description`="Systémoví administrátoři"');
     2215  $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="network-admins" WHERE `Description`="Správci sítě"');
     2216  $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="registered-users" WHERE `Description`="Registrovaní uživatelé"');
     2217  $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="other-users" WHERE `Description`="Ostatní"');
     2218  $Manager->Execute('UPDATE `PermissionGroup` SET `SysName`="customers" WHERE `Description`="Zákazníci"');
    22092219}
    22102220
     
    23172327      907 => array('Revision' => 911, 'Function' => 'UpdateTo911'),
    23182328      911 => array('Revision' => 921, 'Function' => 'UpdateTo921'),
     2329      921 => array('Revision' => 933, 'Function' => 'UpdateTo933'),
    23192330    );
    23202331  }
  • trunk/Application/Version.php

    r922 r934  
    11<?php
    22
    3 $Revision = 922; // Subversion revision
    4 $DatabaseRevision = 921; // SQL structure revision
    5 $ReleaseTime = strtotime('2022-02-28');
     3$Revision = 933; // Subversion revision
     4$DatabaseRevision = 933; // SQL structure revision
     5$ReleaseTime = strtotime('2022-05-11');
  • trunk/Modules/User/UserModel.php

    r924 r934  
    173173              'Locked' => 1));
    174174            $UserId = $this->Database->insert_id;
     175            $PermissionGroup = new PermissionGroup($this->System);
    175176            $this->Database->insert('PermissionUserAssignment', array('User' => $UserId,
    176               'AssignedGroup' => 2));
     177              'AssignedGroup' => $PermissionGroup->GetItemBySysName('registered-users')));
    177178
    178179            $NewPassword = substr(sha1(strtoupper($Login)), 0, 7);
     
    484485    $Desc = new ModelDesc(self::GetClassName());
    485486    $Desc->AddString('Description');
     487    $Desc->AddString('SysName');
     488    $Desc->DefaultValuesMethod = 'GetDefaultValues';
    486489    return $Desc;
     490  }
     491
     492  static function GetDefaultValues(): array
     493  {
     494    return array(
     495      array('Id' => 1, 'Description' => 'Ostatní uživatelé', 'SysName' => 'other-users'),
     496      array('Id' => 2, 'Description' => 'Registrovaní uživatelé', 'SysName' => 'registered-users'),
     497      array('Id' => 3, 'Description' => 'Správci', 'SysName' => 'admins'),
     498    );
     499  }
     500
     501  function GetItemBySysName(string $Name): int
     502  {
     503    $DbResult = $this->Database->select('PermissionGroup', 'Id', '`SysName`="'.$Name.'"');
     504    if ($DbResult->num_rows > 0)
     505    {
     506      $DbRow = $DbResult->fetch_assoc();
     507      return $DbRow['Id'];
     508    } else return 0;
    487509  }
    488510}
  • trunk/Packages/Common/ModelDesc.php

    r923 r934  
    1616    $this->PrimaryKey = 'Id';
    1717    $this->Memory = false;
     18    $this->DefaultValuesMethod = null;
    1819  }
    1920
  • trunk/Packages/Common/Modules/ModuleManager.php

    r912 r934  
    250250        'Type' => ModelColumnType::GetName($Field->Type), 'Nullable' => (int)$Field->Nullable));
    251251    }
     252    if ($ModelDesc->DefaultValues != null)
     253    {
     254      $Values = call_user_func('self::'.$ModelDesc->DefaultValues);
     255      foreach ($Values as $Value)
     256      {
     257        $this->Databse->insert($ModelDesc->Name, $Value);
     258      }
     259    }
    252260  }
    253261
Note: See TracChangeset for help on using the changeset viewer.