From: Alexander Ebert Date: Sun, 4 Nov 2012 19:52:22 +0000 (+0100) Subject: Added application edit form X-Git-Tag: 2.0.0_Beta_1~818^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=de44b8934676e9ce362564d32acb1f91b00c937d;p=GitHub%2FWoltLab%2FWCF.git Added application edit form --- diff --git a/wcfsetup/install/files/acp/templates/applicationEdit.tpl b/wcfsetup/install/files/acp/templates/applicationEdit.tpl new file mode 100644 index 0000000000..c5cf2d0cda --- /dev/null +++ b/wcfsetup/install/files/acp/templates/applicationEdit.tpl @@ -0,0 +1,102 @@ +{include file='header' pageTitle='wcf.acp.application.edit'} + +
+
+

{lang}wcf.acp.application.edit.title{/lang}

+
+
+ +{if $errorField} +

{lang}wcf.global.form.error{/lang}

+{/if} + +{if $success|isset} +

{lang}wcf.global.form.edit.success{/lang}

+{/if} + +
+ +
+ +
+
+
+ {lang}wcf.acp.application.domain{/lang} + + +
+
+ + {lang}wcf.acp.application.domainName.description{/lang} + {if $errorField == 'domainName'} + + {if $errorType == 'empty'} + {lang}wcf.acp.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.application.domainName.error.{$errorType}{/lang} + {/if} + + {/if} +
+ +
+
+
+ + {lang}wcf.acp.application.domainPath.description{/lang} +
+
+
+ +
+ {lang}wcf.acp.application.cookie{/lang} + +

{lang}wcf.acp.application.cookie.warning{/lang}

+ +
+
+
+ + {if $errorField == 'cookieDomain'} + + {if $errorType == 'empty'} + {lang}wcf.acp.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.application.cookieDomain.error.{$errorType}{/lang} + {/if} + + {/if} +
+
+ +
+
+ + {if $errorField == 'cookiePath'} + + {if $errorType == 'empty'} + {lang}wcf.acp.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.application.cookiePath.error.{$errorType}{/lang} + {/if} + + {/if} +
+ +
+ + {event name='fieldsets'} +
+ +
+ +
+
+ +{include file='footer'} diff --git a/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php b/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php new file mode 100644 index 0000000000..0ee6b20e3b --- /dev/null +++ b/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php @@ -0,0 +1,200 @@ + + * @package com.woltlab.wcf + * @subpackage acp.form + * @category Community Framework + */ +class ApplicationEditForm extends ACPForm { + /** + * @see wcf\acp\form\ACPForm::$activeMenuItem + */ + public $activeMenuItem = 'wcf.acp.menu.link.application'; + + /** + * application object + * @var wcf\data\application\Application + */ + public $application = null; + + /** + * cookie domain + * @var string + */ + public $cookieDomain = ''; + + /** + * cookie path + * @var string + */ + public $cookiePath = ''; + + /** + * domain name + * @var string + */ + public $domainName = ''; + + /** + * domain path + * @var string + */ + public $domainPath = ''; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.system.canManageApplication'); + + /** + * application package id + * @var integer + */ + public $packageID = 0; + + /** + * @see wcf\page\AbstractPage::$templateName + */ + public $templateName = 'applicationEdit'; + + /** + * @see wcf\page\IPage::readParameters() + */ + public function readParameters() { + parent::readParameters(); + + if (isset($_REQUEST['id'])) $this->packageID = intval($_REQUEST['id']); + $this->application = new Application($this->packageID); + if (!$this->application->packageID) { + throw new IllegalLinkException(); + } + } + + /** + * @see wcf\form\IForm::readFormParameters() + */ + public function readFormParameters() { + parent::readFormParameters(); + + if (isset($_POST['cookieDomain'])) $this->cookieDomain = StringUtil::trim($_POST['cookieDomain']); + if (isset($_POST['cookiePath'])) $this->cookiePath = StringUtil::trim($_POST['cookiePath']); + if (isset($_POST['domainName'])) $this->domainName = StringUtil::trim($_POST['domainName']); + if (isset($_POST['domainPath'])) $this->domainPath = StringUtil::trim($_POST['domainPath']); + } + + /** + * @see wcf\page\IForm::readData() + */ + public function readData() { + parent::readData(); + + if (empty($_POST)) { + $this->cookieDomain = $this->application->cookieDomain; + $this->cookiePath = $this->application->cookiePath; + $this->domainName = $this->application->domainName; + $this->domainPath = $this->application->domainPath; + } + } + + /** + * @see wcf\form\IForm::validate() + */ + public function validate() { + parent::validate(); + + if (empty($this->domainName)) { + throw new UserInputException('domainName'); + } + else { + $regex = new Regex('^https?\://'); + $this->domainName = FileUtil::removeTrailingSlash($regex->replace($this->domainName, '')); + $this->cookieDomain = FileUtil::removeTrailingSlash($regex->replace($this->cookieDomain, '')); + + // domain may not contain path components + $regex = new Regex('[/#\?&]'); + if ($regex->match($this->domainName)) { + throw new UserInputException('domainName', 'containsPath'); + } + else if ($regex->match($this->cookieDomain)) { + throw new UserInputException('cookieDomain', 'containsPath'); + } + + // check if cookie domain shares the same domain (may exclude subdomains) + if (!StringUtil::endsWith($this->domainName, $this->cookieDomain)) { + throw new UserInputException('cookieDomain', 'notValid'); + } + } + + if (empty($this->domainPath)) { + $this->cookiePath = ''; + } + else { + // strip first and last slash + $this->domainPath = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($this->domainPath)); + $this->cookiePath = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($this->cookiePath)); + + if (!empty($this->cookiePath) && ($this->domainPath != $this->cookiePath)) { + // check if cookie path is contained within domain path + if (!StringUtil::startsWith($this->domainPath, $this->cookiePath)) { + throw new UserInputException('cookiePath', 'notValid'); + } + } + } + + // add slashes + $this->domainPath = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash($this->domainPath)); + $this->cookiePath = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash($this->cookiePath)); + } + + /** + * @see wcf\form\IForm::save() + */ + public function save() { + parent::save(); + + // save application + $this->objectAction = new ApplicationAction(array($this->application), 'update', array('data' => array( + 'cookieDomain' => $this->cookieDomain, + 'cookiePath' => $this->cookiePath, + 'domainName' => $this->domainName, + 'domainPath' => $this->domainPath + ))); + $this->objectAction->executeAction(); + $this->saved(); + + // show success. + WCF::getTPL()->assign(array( + 'success' => true + )); + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'application' => $this->application, + 'cookieDomain' => $this->cookieDomain, + 'cookiePath' => $this->cookiePath, + 'domainName' => $this->domainName, + 'domainPath' => $this->domainPath, + 'packageID' => $this->packageID + )); + } +} diff --git a/wcfsetup/install/files/lib/acp/form/ApplicationGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/ApplicationGroupAddForm.class.php index c24d409a99..749e38f298 100644 --- a/wcfsetup/install/files/lib/acp/form/ApplicationGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ApplicationGroupAddForm.class.php @@ -1,8 +1,7 @@ + + + + + + + + + + + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index ff153f5094..52d3641cbd 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -81,7 +81,7 @@ CREATE TABLE wcf1_application ( domainName VARCHAR(255) NOT NULL, domainPath VARCHAR(255) NOT NULL DEFAULT '/', cookieDomain VARCHAR(255) NOT NULL, - cookieDomainPath VARCHAR(255) NOT NULL DEFAULT '/', + cookiePath VARCHAR(255) NOT NULL DEFAULT '/', groupID INT(10), isPrimary TINYINT(1) NOT NULL DEFAULT 0 );