Merge pull request #5987 from WoltLab/acp-dahsboard-box-hight
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / acp / page / PackageInstallationConfirmPage.class.php
CommitLineData
8059b673 1<?php
a9229942 2
8059b673 3namespace wcf\acp\page;
a9229942 4
8059b673
AE
5use wcf\data\package\installation\queue\PackageInstallationQueue;
6use wcf\page\AbstractPage;
7use wcf\system\exception\IllegalLinkException;
8059b673 8use wcf\system\package\PackageInstallationDispatcher;
a9229942 9use wcf\system\package\validation\PackageValidationManager;
8059b673 10use wcf\system\WCF;
8059b673
AE
11
12/**
13 * Shows a confirmation page prior to start installing.
a9229942
TD
14 *
15 * @author Alexander Ebert
16 * @copyright 2001-2019 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
8059b673 18 */
a9229942
TD
19class PackageInstallationConfirmPage extends AbstractPage
20{
21 /**
22 * @inheritDoc
23 */
24 public $activeMenuItem = 'wcf.acp.menu.link.package.install';
25
26 /**
27 * package installation dispatcher object
28 * @var PackageInstallationDispatcher
29 */
30 public $packageInstallationDispatcher;
31
32 /**
33 * package installation queue object
34 * @var PackageInstallationQueue
35 */
36 public $queue;
37
38 /**
39 * queue id
40 * @var int
41 */
42 public $queueID = 0;
43
44 /**
45 * package validation result
46 * @var bool
47 */
48 public $validationPassed = false;
49
50 /**
51 * true if the package to be installed was uploaded via the import style
52 * form
53 * @var bool
54 */
55 public $installingImportedStyle = false;
56
57 /**
58 * @inheritDoc
59 */
60 public function readParameters()
61 {
62 parent::readParameters();
63
64 if (isset($_REQUEST['queueID'])) {
65 $this->queueID = \intval($_REQUEST['queueID']);
66 }
67 $this->queue = new PackageInstallationQueue($this->queueID);
68 if (!$this->queue->queueID || $this->queue->done) {
69 throw new IllegalLinkException();
70 }
71
72 if ($this->queue->action == 'install') {
73 WCF::getSession()->checkPermissions(['admin.configuration.package.canInstallPackage']);
74 } else {
75 WCF::getSession()->checkPermissions(['admin.configuration.package.canUpdatePackage']);
76 }
77
78 $this->installingImportedStyle = WCF::getSession()->getVar('stylePackageImportLocation') !== null;
79 if ($this->installingImportedStyle) {
80 WCF::getSession()->unregister('stylePackageImportLocation');
81 }
82 }
83
84 /**
85 * @inheritDoc
86 */
87 public function readData()
88 {
89 parent::readData();
90
91 $this->packageInstallationDispatcher = new PackageInstallationDispatcher($this->queue);
92
4891e7da 93 // validate the package and all its requirements
a9229942
TD
94 $this->validationPassed = PackageValidationManager::getInstance()->validate($this->queue->archive, true);
95 }
96
97 /**
98 * @inheritDoc
99 */
100 public function assignVariables()
101 {
102 parent::assignVariables();
103
104 WCF::getTPL()->assign([
105 'archive' => $this->packageInstallationDispatcher->getArchive(),
106 'packageValidationArchives' => PackageValidationManager::getInstance()->getPackageValidationArchiveList(),
107 'queue' => $this->queue,
108 'validationPassed' => $this->validationPassed,
109 'installingImportedStyle' => $this->installingImportedStyle,
110 ]);
111 }
8059b673 112}