aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/MvvI18N.php
blob: 7ff7a6a2ea5609ecc26824d0b9224150e956f6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
/**
 * Translation class with specialised permission check for mvv.
 *
 * @author  Jan-Hendrik Willms <tleilax+studip@gmail.com>
 * @license GPL2 or any later version
 */
class MvvI18N extends I18N
{
    /**
     * MVV: Check user's permissions for an object and set the readonly state
     * accordingly.
     *
     * @param ModuleManagementModel $object Object to check permissions for
     * @param string                $perm   Permission to check (default create)
     * @return I18N object to allow chaining
     */
    public function checkPermission(ModuleManagementModel $object, $perm = MvvPerm::PERM_WRITE)
    {
        $may_edit = MvvPerm::get($object)->haveFieldPerm($field ?: $this->name, $perm);
        return $this->setReadOnly(!$may_edit);
    }
}