Skip to content
Code-Schnipsel Gruppen Projekte
getPermissions.php 900 B
Newer Older
<?php

/**
 * Gets the current users permissions.
 * WARNING: The result can be altered clientside, do not use for security checks.
 */

QUI::$Ajax->registerFunction(
    'package_quiqqer_ckeditor4_ajax_getPermissions',
    function () {
Henning Leutz's avatar
Henning Leutz committed
        $result = [
            'toggle' => false,
            'upload' => false
Henning Leutz's avatar
Henning Leutz committed
        ];

        if (QUI::getUserBySession()->getId() === 0) {
            return $result;
        }


        $User = QUI::getUserBySession();
        if ($User->isSU()) {
Florian Bogner's avatar
Florian Bogner committed
            $result['toggle'] = true;
            $result['upload'] = true;
            return $result;
Florian Bogner's avatar
Florian Bogner committed
        if ($User->getPermission("quiqqer.editors.ckeditor.plugins.toggle")) {
            $result['toggle'] = true;
        }

Florian Bogner's avatar
Florian Bogner committed
        if ($User->getPermission("quiqqer.editors.ckeditor.plugins.upload")) {
            $result['upload'] = true;
        }

        return $result;
Henning Leutz's avatar
Henning Leutz committed
    }