ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilVirusScannerConfigStoredObjective.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 use ILIAS\Setup;
6 
7 class ilVirusScannerConfigStoredObjective implements Setup\Objective
8 {
12  protected $config;
13 
14  public function __construct(
16  ) {
17  $this->config = $config;
18  }
19 
20  public function getHash() : string
21  {
22  return hash("sha256", self::class);
23  }
24 
25  public function getLabel() : string
26  {
27  return "Fill ini with settings for Services/VirusScanner";
28  }
29 
30  public function isNotable() : bool
31  {
32  return false;
33  }
34 
35  public function getPreconditions(Setup\Environment $environment) : array
36  {
37  return [
39  ];
40  }
41 
42  public function achieve(Setup\Environment $environment) : Setup\Environment
43  {
44  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
45 
46  $ini->setVariable("tools", "vscantype", $this->config->getVirusScanner());
47  $ini->setVariable("tools", "scancommand", $this->config->getPathToScan());
48  $ini->setVariable("tools", "cleancommand", $this->config->getPathToClean());
49  $ini->setVariable("tools", "icap_host", $this->config->getIcapHost());
50  $ini->setVariable("tools", "icap_port", $this->config->getIcapPort());
51  $ini->setVariable("tools", "icap_service_name", $this->config->getIcapServiceName());
52  $ini->setVariable("tools", "icap_client_path", $this->config->getIcapClientPath());
53 
54  if (!$ini->write()) {
55  throw new Setup\UnachievableException("Could not write ilias.ini.php");
56  }
57 
58  return $environment;
59  }
60 
64  public function isApplicable(Setup\Environment $environment) : bool
65  {
66  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
67 
68  return
69  $ini->readVariable("tools", "vscantype") !== $this->config->getVirusScanner() ||
70  $ini->readVariable("tools", "scancommand") !== $this->config->getPathToScan() ||
71  $ini->readVariable("tools", "cleancommand") !== $this->config->getPathToClean() ||
72  $ini->readVariable("tools", "icap_host") !== $this->config->getIcapHost() ||
73  $ini->readVariable("tools", "icap_port") !== $this->config->getIcapPort() ||
74  $ini->readVariable("tools", "icap_service_name") !== $this->config->getIcapServiceName() ||
75  $ini->readVariable("tools", "icap_client_path") !== $this->config->getIcapClientPath()
76  ;
77  }
78 }
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:11
$ini
Definition: raiseError.php:4