Added application edit form
authorAlexander Ebert <ebert@woltlab.com>
Sun, 4 Nov 2012 19:52:22 +0000 (20:52 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 4 Nov 2012 19:52:22 +0000 (20:52 +0100)
wcfsetup/install/files/acp/templates/applicationEdit.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/acp/form/ApplicationGroupAddForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/setup/db/install.sql

diff --git a/wcfsetup/install/files/acp/templates/applicationEdit.tpl b/wcfsetup/install/files/acp/templates/applicationEdit.tpl
new file mode 100644 (file)
index 0000000..c5cf2d0
--- /dev/null
@@ -0,0 +1,102 @@
+{include file='header' pageTitle='wcf.acp.application.edit'}
+
+<header class="boxHeadline">
+       <hgroup>
+               <h1>{lang}wcf.acp.application.edit.title{/lang}</h1>
+       </hgroup>
+</header>
+
+{if $errorField}
+       <p class="error">{lang}wcf.global.form.error{/lang}</p>
+{/if}
+
+{if $success|isset}
+       <p class="success">{lang}wcf.global.form.edit.success{/lang}</p>        
+{/if}
+
+<div class="contentNavigation">
+       <nav>
+               <ul>
+                       <li><a href="{link controller='ApplicationManagement'}{/link}" title="{lang}wcf.acp.application.management{/lang}" class="button"><img src="{@$__wcf->getPath()}icon/list.svg" alt="" class="icon24" /> <span>{lang}wcf.acp.application.management{/lang}</span></a></li>
+                       
+                       {event name='largeButtons'}
+               </ul>
+       </nav>
+</div>
+
+<form method="post" action="{link controller='ApplicationEdit' id=$application->packageID}{/link}">
+       <div class="container containerPadding marginTop shadow">
+               <fieldset>
+                       <legend>{lang}wcf.acp.application.domain{/lang}</legend>
+                       
+                       <dl{if $errorField == 'domainName'} class="formError"{/if}>
+                               <dt><label for="domainName">{lang}wcf.acp.application.domainName{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" name="domainName" id="domainName" value="{$domainName}" class="long" />
+                                       <small>{lang}wcf.acp.application.domainName.description{/lang}</small>
+                                       {if $errorField == 'domainName'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'empty'}
+                                                               {lang}wcf.acp.global.form.error.empty{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.application.domainName.error.{$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
+                               </dd>
+                       </dl>
+                       <dl>
+                               <dt><label for="domainPath">{lang}wcf.acp.application.domainPath{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" name="domainPath" id="domainPath" value="{$domainPath}" class="long" />
+                                       <small>{lang}wcf.acp.application.domainPath.description{/lang}</small>
+                               </dd>
+                       </dl>
+               </fieldset>
+               
+               <fieldset>
+                       <legend>{lang}wcf.acp.application.cookie{/lang}</legend>
+                       
+                       <p class="warning">{lang}wcf.acp.application.cookie.warning{/lang}</p>
+                       
+                       <dl class="marginTop {if $errorField == 'cookieDomain'} formError{/if}">
+                               <dt><label for="cookieDomain">{lang}wcf.acp.application.cookieDomain{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" name="cookieDomain" id="cookieDomain" value="{$cookieDomain}" class="long" />
+                                       {if $errorField == 'cookieDomain'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'empty'}
+                                                               {lang}wcf.acp.global.form.error.empty{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.application.cookieDomain.error.{$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
+                               </dd>
+                       </dl>
+                       <dl{if $errorField == 'cookiePath'} class="formError"{/if}>
+                               <dt><label for="cookiePath">{lang}wcf.acp.application.cookiePath{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" name="cookiePath" id="cookiePath" value="{$cookiePath}" class="long" />
+                                       {if $errorField == 'cookiePath'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'empty'}
+                                                               {lang}wcf.acp.global.form.error.empty{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.application.cookiePath.error.{$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
+                               </dd>
+                       </dl>
+               </fieldset>
+               
+               {event name='fieldsets'}
+       </div>
+       
+       <div class="formSubmit">
+               <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+       </div>
+</form>
+
+{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 (file)
index 0000000..0ee6b20
--- /dev/null
@@ -0,0 +1,200 @@
+<?php
+namespace wcf\acp\form;
+use wcf\data\application\Application;
+use wcf\data\application\ApplicationAction;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\UserInputException;
+use wcf\system\Regex;
+use wcf\system\WCF;
+use wcf\util\FileUtil;
+use wcf\util\StringUtil;
+
+/**
+ * Shows the application edit form.
+ * 
+ * @author     Alexander Ebert
+ * @copyright  2001-2012 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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
+               ));
+       }
+}
index c24d409a99ca539c32e7f63b7ab5666e7f0fc0c7..749e38f298256c6d817458c4e2aedbf6c19d9bc1 100644 (file)
@@ -1,8 +1,7 @@
 <?php
 namespace wcf\acp\form;
-use wcf\data\application\group\ApplicationGroupAction;
-
 use wcf\data\application\ApplicationList;
+use wcf\data\application\group\ApplicationGroupAction;
 use wcf\system\exception\UserInputException;
 use wcf\system\WCF;
 use wcf\util\ArrayUtil;
index d6b00ea7434ba94324e12b53721e4d7580037899..5a0e2b0fcd4a81f4137c80de9bba84b44f4fa200 100644 (file)
@@ -5,10 +5,21 @@
        </category>
        
        <category name="wcf.acp.application">
+               <item name="wcf.acp.application.cookie"><![CDATA[Cookie-Einstellungen]]></item>
+               <item name="wcf.acp.application.cookie.warning"><![CDATA[Die folgenden Einstellungen stellen sicher, dass der Login gespeichert wird und ein automatischer Login möglich ist. Sie müssen diese Einstellungen anpassen, sollten sich Domain und/oder Pfad geändert haben. Sollten Sie sich bei den korrekten Werten nicht sicher sein, übernehmen Sie bitte die exakten Angaben der beiden obigen Eingabefelder.]]></item>
                <item name="wcf.acp.application.cookieDomain"><![CDATA[Cookie-Domain]]></item>
+               <item name="wcf.acp.application.cookieDomain.error.containsPfad"><![CDATA[Die Cookie-Domain darf keine Pfadangaben enthalten]]></item>
+               <item name="wcf.acp.application.cookieDomain.error.notValid"><![CDATA[Die Cookie-Domain stimmt nicht mit der oben angegebenen Domain überein (Subdomains wie zum Beispiel &bdquo;www&ldquo; dürfen weggelassen werden).]]></item>
                <item name="wcf.acp.application.cookiePath"><![CDATA[Cookie-Pfad]]></item>
+               <item name="wcf.acp.application.cookiePath.error.notValid"><![CDATA[Der Cookie-Pfad passt nicht zum oben angegebenen Domain-Pfad.]]></item>
+               <item name="wcf.acp.application.domain"><![CDATA[Domain-Einstellungen]]></item>
                <item name="wcf.acp.application.domainName"><![CDATA[Domain]]></item>
+               <item name="wcf.acp.application.domainName.description"><![CDATA[Geben Sie die Domain an, über die diese Anwendung erreichbar ist. Wenn Ihre Anwendung zum Beispiel unter &bdquo;http://www.example.com/community/forum/&ldquo; erreichbar ist, so geben Sie hier bitte &bdquo;www.example.com&ldquo; ein.]]></item>
+               <item name="wcf.acp.application.domainName.error.containsPfad"><![CDATA[Die Domain darf keine Pfadangaben enthalten]]></item>
                <item name="wcf.acp.application.domainPath"><![CDATA[Pfad]]></item>
+               <item name="wcf.acp.application.domainPath.description"><![CDATA[Geben Sie den Pfad an, über den diese Anwendung erreichbar ist. Wenn Ihre Anwendung zum Beispiel unter &bdquo;http://www.example.com/community/forum/&ldquo; erreichbar ist, so geben Sie bitte &bdquo;/community/forum/&ldquo; ein.]]></item>
+               <item name="wcf.acp.application.edit"><![CDATA[Anwendung bearbeiten]]></item>
+               <item name="wcf.acp.application.edit.title"><![CDATA[Anwendung bearbeiten: WoltLab Burning Board]]></item>
                <item name="wcf.acp.application.group.add"><![CDATA[Anwendungsgruppe hinzufügen]]></item>
                <item name="wcf.acp.application.group.applications.error.duplicate"><![CDATA[Zwei oder mehr Anwendungen des selben Typs können nicht in einer Gruppe zusammengefasst werden.]]></item>
                <item name="wcf.acp.application.group.applications.error.notValid"><![CDATA[Eine oder mehrere ausgewählte Anwendungen sind nicht mehr verfügbar.]]></item>
index ff153f5094e659ac2b62aab2767ba1b7142891bf..52d3641cbdb397b62c75b776e3ce267d3e143a62 100644 (file)
@@ -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
 );