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