summaryrefslogtreecommitdiffstats
path: root/application/views/scripts/config/module.phtml
blob: 6d41ab2f4088c29cb96dc47c1a93035e961df07d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<div class="controls">
  <?= $this->tabs ?>
</div>
<div class="content">
  <?php if (! $module): ?>
    <?= $this->translate('There is no such module installed.') ?>
  <?php return; endif ?>
  <?php
    $requiredMods = $module->getRequiredModules();
    $requiredLibs = $module->getRequiredLibraries();
    $restrictions = $module->getProvidedRestrictions();
    $permissions = $module->getProvidedPermissions();
    $unmetDependencies = $moduleManager->hasUnmetDependencies($module->getName());
    $isIcingadbSupported = isset($requiredMods['icingadb']);
    $state = $moduleData->enabled ? ($moduleData->loaded ? 'enabled' : 'failed') : 'disabled';
  ?>
  <table class="name-value-table">
    <tr>
      <th><?= $this->escape($this->translate('Name')) ?></th>
      <td><?= $this->escape($module->getName()) ?></td>
    </tr>
    <tr>
      <th><?= $this->translate('State') ?></th>
      <td>
        <?= $state ?>
      <?php if (isset($this->toggleForm)): ?>
        <?php if ($moduleData->enabled || ! $unmetDependencies): ?>
          <?= $this->toggleForm ?>
        <?php else: ?>
          <?= $this->icon('attention-alt', $this->translate('Module can\'t be enabled due to unmet dependencies')) ?>
        <?php endif ?>
      <?php endif ?>
      </td>
    <tr>
      <th><?= $this->escape($this->translate('Version')) ?></th>
      <td><?= $this->escape($module->getVersion()) ?></td>
    </tr>
    <?php if (isset($moduleGitCommitId) && $moduleGitCommitId !== false): ?>
      <tr>
        <th><?= $this->escape($this->translate('Git commit')) ?></th>
        <td><?= $this->escape($moduleGitCommitId) ?></td>
      </tr>
    <?php endif ?>
    <tr>
      <th><?= $this->escape($this->translate('Description')) ?></th>
      <td>
        <strong><?= $this->escape($module->getTitle()) ?></strong><br>
        <?= nl2br($this->escape($module->getDescription())) ?>
      </td>
    </tr>
    <tr>
      <th><?= $this->escape($this->translate('Dependencies')) ?></th>
      <td class="module-dependencies">
      <?php if (empty($requiredLibs) && empty($requiredMods)): ?>
          <?= $this->translate('This module has no dependencies') ?>
      <?php else: ?>
        <?php if ($unmetDependencies): ?>
          <strong class="unmet-dependencies">
            <?= $this->translate('Unmet dependencies found! Module can\'t be enabled unless all dependencies are met.') ?>
          </strong>
        <?php endif ?>
        <?php if (! empty($requiredLibs)): ?>
          <table class="name-value-table">
              <caption><?= $this->translate('Libraries') ?></caption>
          <?php foreach ($requiredLibs as $libraryName => $versionString): ?>
              <tr>
                  <th><?= $this->escape($libraryName) ?></th>
                  <td>
                  <?php if ($libraries->has($libraryName, $versionString === true ? null : $versionString)): ?>
                      <?= $versionString === true ? '*' : $this->escape($versionString) ?>
                  <?php else: ?>
                      <span class="missing"><?= $versionString === true ? '*' : $this->escape($versionString) ?></span>
                    <?php if (($library = $libraries->get($libraryName)) !== null): ?>
                      (<?= $library->getVersion() ?>)
                    <?php endif ?>
                  <?php endif ?>
                  </td>
              </tr>
          <?php endforeach ?>
          </table>
        <?php endif ?>
        <?php if (! empty($requiredMods)): ?>
          <table class="name-value-table">
              <caption><?= $this->translate('Modules') ?></caption>
          <?php foreach ($requiredMods as $moduleName => $versionString): ?>
              <?php if ($moduleName === 'monitoring' && $isIcingadbSupported && $moduleManager->has('icingadb', $requiredMods['icingadb'])) : ?>
                  <?php continue; ?>
              <?php endif ?>
              <tr>
                  <th><?= $this->escape($moduleName) ?></th>
                  <td>
                  <?php if ($moduleManager->has($moduleName, $versionString === true ? null : $versionString)): ?>
                      <?= $versionString === true ? '*' : $this->escape($versionString) ?>
                  <?php else: ?>
                      <span <?= ($moduleName === 'icingadb' && isset($requiredMods['monitoring']) && $moduleManager->has('monitoring', $requiredMods['monitoring'])) ? 'class="optional"' : 'class="missing"' ?>>
                          <?= $versionString === true ? '*' : $this->escape($versionString) ?>
                      </span>
                    <?php if (! $moduleManager->hasInstalled($moduleName)): ?>
                      (<?= $this->translate('not installed') ?>)
                    <?php else: ?>
                      (<?= $moduleManager->getModule($moduleName, false)->getVersion() ?><?= $moduleManager->hasEnabled($moduleName) ? '' : ', ' . $this->translate('disabled') ?>)
                    <?php endif ?>
                  <?php endif ?>
                  </td>
                  <?php if ($moduleName === 'monitoring' && $isIcingadbSupported) : ?>
                      <td class="or-separator"><?= $this->translate('or') ?></td>
                  <?php endif ?>
              </tr>
          <?php endforeach ?>
          </table>
        <?php endif ?>
      <?php endif ?>
      </td>
    </tr>
    <?php if (! empty($permissions)): ?>
      <tr>
        <th><?= $this->escape($this->translate('Permissions')) ?></th>
        <td>
          <?php foreach ($permissions as $permission): ?>
            <strong><?= $this->escape($permission->name) ?></strong>: <?= $this->escape($permission->description) ?><br />
          <?php endforeach ?>
        </td>
      </tr>
    <?php endif ?>
    <?php if (! empty($restrictions)): ?>
      <tr>
        <th><?= $this->escape($this->translate('Restrictions')) ?></th>
        <td>
          <?php foreach ($restrictions as $restriction): ?>
            <strong><?= $this->escape($restriction->name) ?></strong>: <?= $this->escape($restriction->description) ?><br />
          <?php endforeach ?>
        </td>
      </tr>
    <?php endif ?>
  </table>
</div>