ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\User\Setup\MigrateNewAccountAttachments Class Reference
+ Inheritance diagram for ILIAS\User\Setup\MigrateNewAccountAttachments:
+ Collaboration diagram for ILIAS\User\Setup\MigrateNewAccountAttachments:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 
 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 

Private Attributes

ilResourceStorageMigrationHelper $helper = null
 
int $root_user_id
 

Additional Inherited Members

- Data Fields inherited from ILIAS\Setup\Migration
const INFINITE = -1
 

Detailed Description

Definition at line 25 of file MigrateNewAccountAttachments.php.

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ILIAS\User\Setup\MigrateNewAccountAttachments::getDefaultAmountOfStepsPerRun ( )

Tell the default amount of steps to be executed for one run of the migration.

Return Migration::INFINITE if all units should be migrated at once.

Implements ILIAS\Setup\Migration.

Definition at line 35 of file MigrateNewAccountAttachments.php.

35 : int
36 {
37 return 15;
38 }

◆ getLabel()

ILIAS\User\Setup\MigrateNewAccountAttachments::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 30 of file MigrateNewAccountAttachments.php.

30 : string
31 {
32 return 'Migrate New Account Mail Attachments to IRSS';
33 }

◆ getPreconditions()

ILIAS\User\Setup\MigrateNewAccountAttachments::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 40 of file MigrateNewAccountAttachments.php.

40 : array
41 {
42 return \ilResourceStorageMigrationHelper::getPreconditions();
43 }

◆ getRemainingAmountOfSteps()

ILIAS\User\Setup\MigrateNewAccountAttachments::getRemainingAmountOfSteps ( )

Count up how many "things" need to be migrated.

This helps the admin to decide how big he can create the steps and also how long a migration takes

Implements ILIAS\Setup\Migration.

Definition at line 108 of file MigrateNewAccountAttachments.php.

108 : int
109 {
110 return $this->helper->getDatabase()->fetchObject(
111 $this->helper->getDatabase()->query(
112 'SELECT COUNT(*) cnt FROM mail_template WHERE att_file IS NOT NULL AND type = "nacc"'
113 )
114 )->cnt;
115 }

◆ prepare()

ILIAS\User\Setup\MigrateNewAccountAttachments::prepare ( Environment  $environment)

Prepare the migration by means of some environment.

This is not supposed to modify the environment, but will be run to prime the migration object to run step and getRemainingAmountOfSteps afterwards.

Implements ILIAS\Setup\Migration.

Definition at line 45 of file MigrateNewAccountAttachments.php.

45 : void
46 {
47 $this->helper = new \ilResourceStorageMigrationHelper(
48 new Stakeholder(),
49 $environment
50 );
51 $this->root_user_id = $this->helper->getDatabase()->fetchObject(
52 $this->helper->getDatabase()->query(
53 'SELECT usr_id FROM usr_data WHERE login="root"'
54 )
55 )?->usr_id ?? 6;
56 }

◆ step()

ILIAS\User\Setup\MigrateNewAccountAttachments::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 58 of file MigrateNewAccountAttachments.php.

58 : void
59 {
60 $db = $this->helper->getDatabase();
61 $res = $db->fetchObject(
62 $db->query(
63 'SELECT
64 att_file, lang
65 FROM mail_template
66 WHERE att_file IS NOT NULL AND type = "nacc" LIMIT 1;'
67 )
68 );
69
70 $path = '/' . implode(
71 '/',
72 array_map(
73 static fn(string $path_part): string => trim($path_part, '/'),
74 [
75 $this->helper->getClientDataDir() . '/ilReg/reg_7',
76 $res->lang,
77 ]
78 )
79 );
80
81 $rid = null;
82
83 if (file_exists($path)) {
84 $rid = $this->helper->movePathToStorage(
85 $path,
86 $this->root_user_id,
87 static fn() => $res->att_file,
88 static fn() => $res->att_file
89 );
90 }
91 if ($rid !== null) {
92 $rid = $rid->serialize();
93 }
94
95 $db->update(
96 'mail_template',
97 [
98 'att_file' => [\ilDBConstants::T_TEXT, null],
99 'att_rid' => [\ilDBConstants::T_TEXT, $rid]
100 ],
101 [
102 'lang' => [\ilDBConstants::T_TEXT, $res->lang],
103 'type' => [\ilDBConstants::T_TEXT, 'nacc'],
104 ]
105 );
106 }
$path
Definition: ltiservices.php:30
$res
Definition: ltiservices.php:69

References ILIAS\$db, $path, $res, and ilDBConstants\T_TEXT.

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ILIAS\User\Setup\MigrateNewAccountAttachments::$helper = null
private

Definition at line 27 of file MigrateNewAccountAttachments.php.

◆ $root_user_id

int ILIAS\User\Setup\MigrateNewAccountAttachments::$root_user_id
private

Definition at line 28 of file MigrateNewAccountAttachments.php.


The documentation for this class was generated from the following file: