aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/MvvI18N.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:07:19 +0200
committerJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:19:12 +0200
commita3da1483a9e689846179159355badfec8073dbec (patch)
tree770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /lib/classes/MvvI18N.php
current code from svn, revision 62608
Diffstat (limited to 'lib/classes/MvvI18N.php')
-rw-r--r--lib/classes/MvvI18N.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/classes/MvvI18N.php b/lib/classes/MvvI18N.php
new file mode 100644
index 0000000..7ff7a6a
--- /dev/null
+++ b/lib/classes/MvvI18N.php
@@ -0,0 +1,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);
+ }
+}