Completed
Push — development ( f93eb8...ffa1a0 )
by Thomas
20s
created

htdocs/lib2/translateAccess.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/***************************************************************************
3
 * for license information see LICENSE.md
4
 ***************************************************************************/
5
6
require_once __DIR__ . '/logic/const.inc.php';
7
8
/**
9
 * Class translateAccess
10
 */
11
class translateAccess
12
{
13
    private $languages = false;
14
15
    /**
16
     * @return bool
17
     */
18
    public function hasAccess()
19
    {
20
        global $login;
21
22
        if (isset($login)) {
23
            return $login->hasAdminPriv(ADMIN_TRANSLATE);
24
        }
25
26
        return false;
27
    }
28
29
    /**
30
     * @param $language
31
     *
32
     * @return bool
33
     */
34
    public function mayTranslate($language)
35
    {
36
        global $login;
37
38
        if (isset($login)) {
39
            return $login->hasAdminPriv(ADMIN_ROOT) || in_array($language, $this->getLanguages());
40
        }
41
42
        return false;
43
    }
44
45
    /**
46
     * @return bool
47
     */
48
    private function getLanguages()
49
    {
50
        if ($this->languages === false) {
51
            $this->loadLanguages();
52
        }
53
54
        return $this->languages;
55
    }
56
57
    /**
58
     *
59
     */
60
    private function loadLanguages()
61
    {
62
        global $login;
63
64
        $options = new useroptions($login->userid);
65
66
        $this->languages = explode(',', $options->getOptValue(USR_OPT_TRANSLANG));
0 ignored issues
show
Documentation Bug introduced by
It seems like explode(',', $options->g...lue(USR_OPT_TRANSLANG)) of type array is incompatible with the declared type boolean of property $languages.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
67
    }
68
}
69