From 005f6926bb80888b6d0e53231428a9ca4b7aff74 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 23 Aug 2013 19:30:10 +0200 Subject: [PATCH] Moved group description column into wcf --- com.woltlab.wcf/templates/team.tpl | 1 + .../files/acp/templates/userGroupAdd.tpl | 14 +++++++++++ .../lib/acp/form/UserGroupAddForm.class.php | 23 +++++++++++++++++-- .../lib/acp/form/UserGroupEditForm.class.php | 11 +++++++++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + wcfsetup/setup/db/install.sql | 1 + 7 files changed, 50 insertions(+), 2 deletions(-) diff --git a/com.woltlab.wcf/templates/team.tpl b/com.woltlab.wcf/templates/team.tpl index ef3519bb41..f488421c55 100644 --- a/com.woltlab.wcf/templates/team.tpl +++ b/com.woltlab.wcf/templates/team.tpl @@ -53,6 +53,7 @@ {foreach from=$objects->getTeams() item=team}

{$team->groupName|language} {#$team->getMembers()|count}

+

{$team->groupDescription|language}

diff --git a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl index 9f21a8273a..7d43585957 100644 --- a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl @@ -58,6 +58,20 @@ + +
+
+ + {if $errorType.groupDescription|isset} + + {lang}wcf.acp.group.description.error.{@$errorType.groupDescription}{/lang} + + {/if} + + {include file='multipleLanguageInputJavascript' elementIdentifier='groupDescription' forceSelection=false} +
+ +
diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php index f0118e7438..d3a0ba5aea 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php @@ -54,6 +54,12 @@ class UserGroupAddForm extends AbstractOptionListForm { */ public $groupName = ''; + /** + * group description + * @var string + */ + protected $groupDescription = ''; + /** * additional fields * @var array @@ -91,6 +97,7 @@ class UserGroupAddForm extends AbstractOptionListForm { parent::readParameters(); I18nHandler::getInstance()->register('groupName'); + I18nHandler::getInstance()->register('groupDescription'); } /** @@ -102,6 +109,7 @@ class UserGroupAddForm extends AbstractOptionListForm { I18nHandler::getInstance()->readValues(); if (I18nHandler::getInstance()->isPlainValue('groupName')) $this->groupName = I18nHandler::getInstance()->getValue('groupName'); + if (I18nHandler::getInstance()->isPlainValue('groupDescription')) $this->groupDescription = I18nHandler::getInstance()->getValue('groupDescription'); if (isset($_POST['priority'])) $this->priority = intval($_POST['priority']); if (isset($_POST['userOnlineMarking'])) $this->userOnlineMarking = StringUtil::trim($_POST['userOnlineMarking']); @@ -143,6 +151,7 @@ class UserGroupAddForm extends AbstractOptionListForm { $data = array( 'data' => array_merge($this->additionalFields, array( 'groupName' => $this->groupName, + 'groupDescription' => $this->groupDescription, 'priority' => $this->priority, 'userOnlineMarking' => $this->userOnlineMarking, 'showOnTeamPage' => $this->showOnTeamPage @@ -151,10 +160,10 @@ class UserGroupAddForm extends AbstractOptionListForm { ); $this->objectAction = new UserGroupAction(array(), 'create', $data); $this->objectAction->executeAction(); + $returnValues = $this->objectAction->getReturnValues(); + $groupID = $returnValues['returnValues']->groupID; if (!I18nHandler::getInstance()->isPlainValue('groupName')) { - $returnValues = $this->objectAction->getReturnValues(); - $groupID = $returnValues['returnValues']->groupID; I18nHandler::getInstance()->save('groupName', 'wcf.acp.group.group'.$groupID, 'wcf.acp.group', 1); // update group name @@ -163,6 +172,15 @@ class UserGroupAddForm extends AbstractOptionListForm { 'groupName' => 'wcf.acp.group.group'.$groupID )); } + if (!I18nHandler::getInstance()->isPlainValue('groupDescription')) { + I18nHandler::getInstance()->save('groupDescription', 'wcf.acp.group.groupDescription'.$groupID, 'wcf.acp.group', 1); + + // update group name + $groupEditor = new UserGroupEditor($returnValues['returnValues']); + $groupEditor->update(array( + 'groupDescription' => 'wcf.acp.group.groupDescription'.$groupID + )); + } $this->saved(); @@ -200,6 +218,7 @@ class UserGroupAddForm extends AbstractOptionListForm { WCF::getTPL()->assign(array( 'groupName' => $this->groupName, + 'groupDescription' => $this->groupDescription, 'optionTree' => $this->optionTree, 'action' => 'add', 'priority' => $this->priority, diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php index d26af730f5..4cce626583 100755 --- a/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php @@ -68,7 +68,9 @@ class UserGroupEditForm extends UserGroupAddForm { public function readData() { if (empty($_POST)) { I18nHandler::getInstance()->setOptions('groupName', 1, $this->group->groupName, 'wcf.acp.group.group\d+'); + I18nHandler::getInstance()->setOptions('groupDescription', 1, $this->group->groupDescription, 'wcf.acp.group.groupDescription\d+'); $this->groupName = $this->group->groupName; + $this->groupDescription = $this->group->groupDescription; $this->priority = $this->group->priority; $this->userOnlineMarking = $this->group->userOnlineMarking; $this->showOnTeamPage = $this->group->showOnTeamPage; @@ -132,10 +134,19 @@ class UserGroupEditForm extends UserGroupAddForm { else { I18nHandler::getInstance()->save('groupName', $this->groupName, 'wcf.acp.group', 1); } + $this->groupDescription = 'wcf.acp.group.groupDescription'.$this->group->groupID; + if (I18nHandler::getInstance()->isPlainValue('groupDescription')) { + I18nHandler::getInstance()->remove($this->groupDescription); + $this->groupDescription = I18nHandler::getInstance()->getValue('groupDescription'); + } + else { + I18nHandler::getInstance()->save('groupDescription', $this->groupDescription, 'wcf.acp.group', 1); + } $data = array( 'data' => array_merge(array( 'groupName' => $this->groupName, + 'groupDescription' => $this->groupDescription, 'priority' => $this->priority, 'userOnlineMarking' => $this->userOnlineMarking, 'showOnTeamPage' => $this->showOnTeamPage diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index de80266744..fb8467824c 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -354,6 +354,7 @@ + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 0928ac829b..fa9cde2fcd 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -353,6 +353,7 @@ Examples for medium ID detection: + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index a9e433aae4..043dccadc7 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -1050,6 +1050,7 @@ DROP TABLE IF EXISTS wcf1_user_group; CREATE TABLE wcf1_user_group ( groupID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, groupName VARCHAR(255) NOT NULL DEFAULT '', + groupDescription TEXT, groupType TINYINT(1) NOT NULL DEFAULT 4, priority MEDIUMINT(8) NOT NULL DEFAULT 0, userOnlineMarking VARCHAR(255) NOT NULL DEFAULT '%s', -- 2.20.1