2 * Manages user permissions.
4 * @author Matthias Schmidt
5 * @copyright 2001-2017 WoltLab GmbH
6 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7 * @module WoltLabSuite/Core/Permission
9 define(['Dictionary'], function(Dictionary
) {
12 var _permissions
= new Dictionary();
15 * @exports WoltLabSuite/Core/Permission
19 * Adds a single permission to the store.
21 * @param {string} permission permission name
22 * @param {boolean} value permission value
24 add: function(permission
, value
) {
25 if (typeof value
!== "boolean") {
26 throw new TypeError("Permission value has to be boolean.");
29 _permissions
.set(permission
, value
);
33 * Adds all the permissions in the given object to the store.
35 * @param {Object.<string, boolean>} object permission list
37 addObject: function(object
) {
38 for (var key
in object
) {
39 if (objOwns(object
, key
)) {
40 this.add(key
, object
[key
]);
46 * Returns the value of a permission.
48 * If the permission is unknown, false is returned.
50 * @param {string} permission permission name
51 * @return {boolean} permission value
53 get: function(permission
) {
54 if (_permissions
.has(permission
)) {
55 return _permissions
.get(permission
);