2 namespace wcf\acp\form
;
3 use wcf\data\user\rank\UserRank
;
4 use wcf\data\user\rank\UserRankAction
;
5 use wcf\form\AbstractForm
;
6 use wcf\system\exception\IllegalLinkException
;
7 use wcf\system\language\I18nHandler
;
11 * Shows the user rank edit form.
14 * @copyright 2001-2014 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package com.woltlab.wcf
17 * @subpackage acp.form
18 * @category Community Framework
20 class UserRankEditForm
extends UserRankAddForm
{
22 * @see \wcf\page\AbstractPage::$activeMenuItem
24 public $activeMenuItem = 'wcf.acp.menu.link.user.rank.list';
34 * @var \wcf\data\user\rank\UserRank
39 * @see \wcf\page\IPage::readParameters()
41 public function readParameters() {
42 parent
::readParameters();
44 if (isset($_REQUEST['id'])) $this->rankID
= intval($_REQUEST['id']);
45 $this->rank
= new UserRank($this->rankID
);
46 if (!$this->rank
->rankID
) {
47 throw new IllegalLinkException();
52 * @see \wcf\form\IForm::save()
54 public function save() {
57 $this->rankTitle
= 'wcf.user.rank.userRank'.$this->rank
->rankID
;
58 if (I18nHandler
::getInstance()->isPlainValue('rankTitle')) {
59 I18nHandler
::getInstance()->remove($this->rankTitle
);
60 $this->rankTitle
= I18nHandler
::getInstance()->getValue('rankTitle');
63 I18nHandler
::getInstance()->save('rankTitle', $this->rankTitle
, 'wcf.user', 1);
67 $this->objectAction
= new UserRankAction(array($this->rank
), 'update', array('data' => array_merge($this->additionalFields
, array(
68 'rankTitle' => $this->rankTitle
,
69 'cssClassName' => ($this->cssClassName
== 'custom' ?
$this->customCssClassName
: $this->cssClassName
),
70 'groupID' => $this->groupID
,
71 'requiredPoints' => $this->requiredPoints
,
72 'rankImage' => $this->rankImage
,
73 'repeatImage' => $this->repeatImage
,
74 'requiredGender' => $this->requiredGender
76 $this->objectAction
->executeAction();
79 // reset values if non-custom value was choosen
80 if ($this->cssClassName
!= 'custom') $this->customCssClassName
= '';
83 WCF
::getTPL()->assign(array(
89 * @see \wcf\page\IPage::readData()
91 public function readData() {
95 I18nHandler
::getInstance()->setOptions('rankTitle', 1, $this->rank
->rankTitle
, 'wcf.user.rank.userRank\d+');
96 $this->rankTitle
= $this->rank
->rankTitle
;
97 $this->cssClassName
= $this->rank
->cssClassName
;
98 if (!in_array($this->cssClassName
, $this->availableCssClassNames
)) {
99 $this->customCssClassName
= $this->cssClassName
;
100 $this->cssClassName
= 'custom';
102 $this->groupID
= $this->rank
->groupID
;
103 $this->requiredPoints
= $this->rank
->requiredPoints
;
104 $this->requiredGender
= $this->rank
->requiredGender
;
105 $this->repeatImage
= $this->rank
->repeatImage
;
106 $this->rankImage
= $this->rank
->rankImage
;
111 * @see \wcf\page\IPage::assignVariables()
113 public function assignVariables() {
114 parent
::assignVariables();
116 I18nHandler
::getInstance()->assignVariables(!empty($_POST));
118 WCF
::getTPL()->assign(array(
119 'rankID' => $this->rankID
,
120 'rank' => $this->rank
,