ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilFileObjectSettingsUpdatedObjective.php
Go to the documentation of this file.
1 <?php
2 
19 use ILIAS\Setup;
21 
22 class ilFileObjectSettingsUpdatedObjective implements Setup\Objective
23 {
24  public function getHash(): string
25  {
26  return hash(
27  "sha256",
28  static::class
29  );
30  }
31 
32  public function getLabel(): string
33  {
34  return "File Object Settings have been updated.";
35  }
36 
37  public function isNotable(): bool
38  {
39  return false;
40  }
41 
42  public function getPreconditions(Environment $environment): array
43  {
44  return [
47  ];
48  }
49 
50  public function achieve(Environment $environment): Environment
51  {
56  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
57  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
58 
59  $use_ascii_characters_only = $client_ini->readVariable(
60  'file_access',
61  'disable_ascii'
62  ) !== '1';
63 
64  $db->manipulateF(
65  "INSERT IGNORE settings (module, keyword, value) VALUES (%s, %s, %s)",
66  ['text', 'text', 'text'],
67  ['file_access', 'download_ascii_filename', $use_ascii_characters_only ? '1' : '0']
68  );
69 
70  $db->manipulate(
71  "UPDATE settings SET module = 'file_access' WHERE keyword = 'bgtask_download'"
72  );
73 
74  $client_ini->removeGroup('file_access');
75  $client_ini->write();
76 
77  return $environment;
78  }
79 
80  public function isApplicable(Environment $environment): bool
81  {
85  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
86 
87  return $client_ini->groupExists("file_access");
88  }
89 }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27