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