Profile::haveUserRight PHP Method

haveUserRight() static public method

function to check one right of a user
static public haveUserRight ( $user, $right, $valright, $entity ) : boolean
$user integer id of the user to check rights
$right string right to check
$valright integer/string/array value of the rights searched
$entity integer id of the entity
return boolean
    static function haveUserRight($user, $right, $valright, $entity)
    {
        global $DB;
        $query = "SELECT {$right}\n                FROM `glpi_profiles`\n                INNER JOIN `glpi_profiles_users`\n                   ON (`glpi_profiles`.`id` = `glpi_profiles_users`.`profiles_id`)\n                WHERE `glpi_profiles_users`.`users_id` = '{$user}'\n                      AND {$right} IN ('{$valright}') " . getEntitiesRestrictRequest(" AND ", "glpi_profiles_users", '', $entity, true);
        if ($result = $DB->query($query)) {
            if ($DB->numrows($result)) {
                return true;
            }
        }
        return false;
    }