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> | |
a9229942 | 13 | * @since 3.0 |
625136ac | 14 | */ |
a9229942 TD |
15 | trait TDatabaseObjectPermissions |
16 | { | |
17 | /** | |
18 | * Returns true if the active user has at least one permission required | |
19 | * by this object. | |
20 | * | |
21 | * @return bool | |
22 | */ | |
23 | public function validatePermissions() | |
24 | { | |
25 | if ($this->permissions) { | |
26 | $permissions = \explode(',', $this->permissions); | |
27 | foreach ($permissions as $permission) { | |
28 | if (WCF::getSession()->getPermission($permission)) { | |
29 | return true; | |
30 | } | |
31 | } | |
32 | ||
33 | return false; | |
34 | } | |
35 | ||
36 | return true; | |
37 | } | |
625136ac | 38 | } |