Fix `Ui/Message/Manager.getPermission()` for permissions with dashes
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / TDatabaseObjectPermissions.class.php
CommitLineData
625136ac
MS
1<?php
2namespace wcf\data;
3use wcf\system\WCF;
4
5/**
6 * Provides a method for validating database object permissions.
7 *
8 * @author Matthias Schmidt
7b7b9764 9 * @copyright 2001-2019 WoltLab GmbH
625136ac 10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
e71525e4
MW
11 * @package WoltLabSuite\Core\Data
12 * @since 3.0
625136ac
MS
13 */
14trait TDatabaseObjectPermissions {
15 /**
16 * Returns true if the active user has at least one permission required
17 * by this object.
18 *
1524f8c0 19 * @return bool
625136ac
MS
20 */
21 public function validatePermissions() {
22 if ($this->permissions) {
23 $permissions = explode(',', $this->permissions);
24 foreach ($permissions as $permission) {
25 if (WCF::getSession()->getPermission($permission)) {
26 return true;
27 }
28 }
29
30 return false;
31 }
32
33 return true;
34 }
35}