<parent>wcf.acp.menu.link.user.management</parent>
<permissions>admin.user.canMailUser</permissions>
</acpmenuitem>
+
+ <acpmenuitem name="wcf.acp.menu.link.user.profileMenu">
+ <controller>wcf\acp\page\UserProfileMenuPage</controller>
+ <parent>wcf.acp.menu.link.user.management</parent>
+ <permissions>admin.user.canManageUserOption</permissions>
+ </acpmenuitem>
<!-- /management -->
<!-- group -->
<ul>
{foreach from=$__wcf->getUserProfileMenu()->getMenuItems() item=menuItem}
{if $menuItem->getContentManager()->isVisible($userID)}
- <li><a href="{$__wcf->getAnchor($menuItem->getIdentifier())}">{lang}wcf.user.profile.menu.{@$menuItem->menuItem}{/lang}</a></li>
+ <li><a href="{$__wcf->getAnchor($menuItem->getIdentifier())}">{$menuItem}</a></li>
{/if}
{/foreach}
</ul>
--- /dev/null
+{include file='header' pageTitle='wcf.acp.user.profileMenu.sort'}
+
+<script data-relocate="true">
+ require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
+ new UiSortableList({
+ containerId: 'userProfileMenuItemList',
+ className: 'wcf\\data\\user\\profile\\menu\\item\\UserProfileMenuItemAction',
+ isSimpleSorting: true
+ });
+ });
+</script>
+
+<header class="contentHeader">
+ <div class="contentHeaderTitle">
+ <h1 class="contentTitle">{lang}wcf.acp.user.profileMenu.sort{/lang}</h1>
+ </div>
+
+ {hascontent}
+ <nav class="contentHeaderNavigation">
+ <ul>
+ {content}{event name='contentHeaderNavigation'}{/content}
+ </ul>
+ </nav>
+ {/hascontent}
+</header>
+
+<div id="userProfileMenuItemList" class="section">
+ <ol class="sortableList" data-object-id="0">
+ {foreach from=$userProfileMenuItemList item=menuItem}
+ <li class="sortableNode" data-object-id="{@$menuItem->menuItemID}">
+ <span class="sortableNodeLabel">
+ <span>{$menuItem}</span>
+
+ <span class="statusDisplay sortableButtonContainer">
+ <span class="icon icon16 fa-arrows sortableNodeHandle"></span>
+ </span>
+ </span>
+ </li>
+ {/foreach}
+ </ol>
+</div>
+
+<div class="formSubmit">
+ <button class="button buttonPrimary" data-type="submit">{lang}wcf.global.button.saveSorting{/lang}</button>
+</div>
+
+{include file='footer'}
--- /dev/null
+<?php
+namespace wcf\acp\page;
+use wcf\data\user\profile\menu\item\UserProfileMenuItemList;
+use wcf\page\AbstractPage;
+use wcf\system\WCF;
+
+/**
+ * Provides sorting capabilities for the user profile menu.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Acp\Page
+ */
+class UserProfileMenuPage extends AbstractPage {
+ /**
+ * @inheritDoc
+ */
+ public $activeMenuItem = 'wcf.acp.menu.link.user.profileMenu';
+
+ /**
+ * @inheritDoc
+ */
+ public $neededPermissions = ['admin.user.canManageUserOption'];
+
+ /**
+ * user profile menu item list object
+ * @var UserProfileMenuItemList
+ */
+ public $userProfileMenuItemList;
+
+ /**
+ * @inheritDoc
+ */
+ public function readData() {
+ parent::readData();
+
+ $this->userProfileMenuItemList = new UserProfileMenuItemList();
+ $this->userProfileMenuItemList->sqlOrderBy = "showOrder";
+ $this->userProfileMenuItemList->readObjects();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function assignVariables() {
+ parent::assignVariables();
+
+ WCF::getTPL()->assign([
+ 'userProfileMenuItemList' => $this->userProfileMenuItemList
+ ]);
+ }
+}
use wcf\data\TDatabaseObjectPermissions;
use wcf\system\exception\SystemException;
use wcf\system\SingletonFactory;
+use wcf\system\WCF;
/**
* Represents an user profile menu item.
return $this->contentManager;
}
+
+ /**
+ * @return string
+ */
+ public function __toString() {
+ return WCF::getLanguage()->get('wcf.user.profile.menu.' . $this->menuItem);
+ }
}
<?php
namespace wcf\data\user\profile\menu\item;
use wcf\data\AbstractDatabaseObjectAction;
+use wcf\data\ISortableAction;
+use wcf\system\cache\builder\UserProfileMenuCacheBuilder;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\menu\user\profile\UserProfileMenu;
+use wcf\system\WCF;
+use wcf\util\ArrayUtil;
/**
* Executes user profile menu item-related actions.
* @method UserProfileMenuItemEditor[] getObjects()
* @method UserProfileMenuItemEditor getSingleObject()
*/
-class UserProfileMenuItemAction extends AbstractDatabaseObjectAction {
+class UserProfileMenuItemAction extends AbstractDatabaseObjectAction implements ISortableAction {
/**
* @inheritDoc
*/
* menu item
* @var UserProfileMenuItem
*/
- protected $menuItem = null;
+ protected $menuItem;
+
+ /**
+ * @inheritDoc
+ */
+ protected $requireACP = ['updatePosition'];
/**
* Validates menu item.
'template' => $contentManager->getContent($this->parameters['data']['userID'])
];
}
+
+ /**
+ * @inheritDoc
+ */
+ public function validateUpdatePosition() {
+ WCF::getSession()->checkPermissions(['admin.user.canManageUserOption']);
+
+ if (!isset($this->parameters['data']['structure'][0])) {
+ throw new UserInputException('structure');
+ }
+
+ $sql = "SELECT menuItemID
+ FROM wcf".WCF_N."_user_profile_menu_item";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute();
+ $menuItemIDs = [];
+ while ($menuItemID = $statement->fetchColumn()) {
+ $menuItemIDs[$menuItemID] = $menuItemID;
+ }
+
+ $this->parameters['data']['structure'][0] = ArrayUtil::toIntegerArray($this->parameters['data']['structure'][0]);
+ foreach ($this->parameters['data']['structure'][0] as $menuItemID) {
+ if (!isset($menuItemIDs[$menuItemID])) {
+ throw new UserInputException('structure');
+ }
+
+ unset($menuItemIDs[$menuItemID]);
+ }
+
+ if (!empty($menuItemIDs)) {
+ throw new UserInputException('structure');
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function updatePosition() {
+ $sql = "UPDATE wcf".WCF_N."_user_profile_menu_item
+ SET showOrder = ?
+ WHERE menuItemID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+
+ WCF::getDB()->beginTransaction();
+ for ($i = 0, $length = count($this->parameters['data']['structure'][0]); $i < $length; $i++) {
+ $statement->execute([
+ $i,
+ $this->parameters['data']['structure'][0][$i]
+ ]);
+ }
+ WCF::getDB()->commitTransaction();
+
+ // reset cache
+ UserProfileMenuCacheBuilder::getInstance()->reset();
+ }
}
<?php
namespace wcf\page;
+use wcf\data\object\type\ObjectType;
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\follow\UserFollowerList;
use wcf\data\user\follow\UserFollowingList;
/**
* overview editable content object type
- * @var \wcf\data\object\type\ObjectType
+ * @var ObjectType
*/
public $objectType;
<item name="wcf.acp.menu.link.user.option.category.list"><![CDATA[Profilfeld-Kategorien]]></item>
<item name="wcf.acp.menu.link.user.option.category.add"><![CDATA[Profilfeld-Kategorie hinzufügen]]></item>
<item name="wcf.acp.menu.link.userOptionDefaults"><![CDATA[Benutzerprofil-Einstellungen]]></item>
+ <item name="wcf.acp.menu.link.user.profileMenu"><![CDATA[Benutzerprofil-Menü]]></item>
<item name="wcf.acp.menu.link.template"><![CDATA[Templates]]></item>
<item name="wcf.acp.menu.link.template.list"><![CDATA[Templates]]></item>
<item name="wcf.acp.menu.link.template.add"><![CDATA[Template hinzufügen]]></item>
<item name="wcf.acp.user.bulkProcessing.sendMail"><![CDATA[E-Mail an Benutzer senden]]></item>
<item name="wcf.acp.user.bulkProcessing.success"><![CDATA[Die gewählte Aktion wurde auf {#$affectedObjectCount} Benutzer ausgeführt.]]></item>
<item name="wcf.acp.user.bulkProcessing.warning"><![CDATA[Die Massenbearbeitung von Benutzern führt die unten ausgewählte Aktion <b>ohne zusätzliche Sicherheitsabfrage</b> bei allen Benutzern aus, die unter die eingestellten Bedingungen fallen.]]></item>
+ <item name="wcf.acp.user.profileMenu.sort"><![CDATA[Benutzerprofil-Menü Sortierung]]></item>
</category>
<category name="wcf.acp.worker">
<item name="wcf.acp.menu.link.user.option.category.list"><![CDATA[Field Categories]]></item>
<item name="wcf.acp.menu.link.user.option.category.add"><![CDATA[Add Field Category]]></item>
<item name="wcf.acp.menu.link.userOptionDefaults"><![CDATA[User Field Settings]]></item>
+ <item name="wcf.acp.menu.link.user.profileMenu"><![CDATA[User Profile Menu]]></item>
<item name="wcf.acp.menu.link.template"><![CDATA[Templates]]></item>
<item name="wcf.acp.menu.link.template.list"><![CDATA[Templates]]></item>
<item name="wcf.acp.menu.link.template.add"><![CDATA[Add Template]]></item>
<item name="wcf.acp.user.bulkProcessing.sendMail"><![CDATA[Send Email to Users]]></item>
<item name="wcf.acp.user.bulkProcessing.success"><![CDATA[The selection action has been executed and affected {#$affectedObjectCount} user{if $affectedObjectCount != 1}s{/if}.]]></item>
<item name="wcf.acp.user.bulkProcessing.warning"><![CDATA[Heads up! The bulk processing executes all actions below on all users matching the selected conditions without any further confirmation prompt!]]></item>
+ <item name="wcf.acp.user.profileMenu.sort"><![CDATA[User Profile Menu Show Order]]></item>
</category>
<category name="wcf.acp.worker">