2 namespace wcf\acp\form
;
3 use wcf\data\package\update\server\PackageUpdateServer
;
4 use wcf\data\package\update\server\PackageUpdateServerAction
;
5 use wcf\form\AbstractForm
;
6 use wcf\system\exception\UserInputException
;
9 use wcf\util\StringUtil
;
12 * Shows the server add form.
15 * @copyright 2001-2016 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\Acp\Form
19 class PackageUpdateServerAddForm
extends AbstractForm
{
23 public $activeMenuItem = 'wcf.acp.menu.link.package';
28 public $neededPermissions = ['admin.configuration.package.canEditServer'];
34 public $serverURL = '';
37 * server login username
40 public $loginUsername = '';
43 * server login password
46 public $loginPassword = '';
51 public function readFormParameters() {
52 parent
::readFormParameters();
54 if (isset($_POST['serverURL'])) $this->serverURL
= StringUtil
::trim($_POST['serverURL']);
55 if (isset($_POST['loginUsername'])) $this->loginUsername
= $_POST['loginUsername'];
56 if (isset($_POST['loginPassword'])) $this->loginPassword
= $_POST['loginPassword'];
62 public function validate() {
65 if (empty($this->serverURL
)) {
66 throw new UserInputException('serverURL');
69 if (!PackageUpdateServer
::isValidServerURL($this->serverURL
)) {
70 throw new UserInputException('serverURL', 'invalid');
77 public function save() {
81 $this->objectAction
= new PackageUpdateServerAction([], 'create', ['data' => array_merge($this->additionalFields
, [
82 'serverURL' => $this->serverURL
,
83 'loginUsername' => $this->loginUsername
,
84 'loginPassword' => $this->loginPassword
86 $this->objectAction
->executeAction();
90 $this->serverURL
= $this->loginUsername
= $this->loginPassword
= '';
92 // show success message
93 WCF
::getTPL()->assign('success', true);
99 public function assignVariables() {
100 parent
::assignVariables();
102 WCF
::getTPL()->assign([
103 'serverURL' => $this->serverURL
,
104 'loginUsername' => $this->loginUsername
,
105 'loginPassword' => $this->loginPassword
,
113 public function show() {
114 // check master password
115 WCFACP
::checkMasterPassword();