Reminder::haveVisibilityAccess PHP Method

haveVisibilityAccess() public method

Is the login user have access to reminder based on visibility configuration
public haveVisibilityAccess ( ) : boolean
return boolean
    function haveVisibilityAccess()
    {
        // No public reminder right : no visibility check
        if (!self::canView()) {
            return false;
        }
        // Author
        if ($this->fields['users_id'] == Session::getLoginUserID()) {
            return true;
        }
        // Users
        if (isset($this->users[Session::getLoginUserID()])) {
            return true;
        }
        // Groups
        if (count($this->groups) && isset($_SESSION["glpigroups"]) && count($_SESSION["glpigroups"])) {
            foreach ($this->groups as $key => $data) {
                foreach ($data as $group) {
                    if (in_array($group['groups_id'], $_SESSION["glpigroups"])) {
                        // All the group
                        if ($group['entities_id'] < 0) {
                            return true;
                        }
                        // Restrict to entities
                        $entities = array($group['entities_id']);
                        if ($group['is_recursive']) {
                            $entities = getSonsOf('glpi_entities', $group['entities_id']);
                        }
                        if (Session::haveAccessToOneOfEntities($entities, true)) {
                            return true;
                        }
                    }
                }
            }
        }
        // Entities
        if (count($this->entities) && isset($_SESSION["glpiactiveentities"]) && count($_SESSION["glpiactiveentities"])) {
            foreach ($this->entities as $key => $data) {
                foreach ($data as $entity) {
                    $entities = array($entity['entities_id']);
                    if ($entity['is_recursive']) {
                        $entities = getSonsOf('glpi_entities', $entity['entities_id']);
                    }
                    if (Session::haveAccessToOneOfEntities($entities, true)) {
                        return true;
                    }
                }
            }
        }
        // Profiles
        if (count($this->profiles) && isset($_SESSION["glpiactiveprofile"]) && isset($_SESSION["glpiactiveprofile"]['id'])) {
            if (isset($this->profiles[$_SESSION["glpiactiveprofile"]['id']])) {
                foreach ($this->profiles[$_SESSION["glpiactiveprofile"]['id']] as $profile) {
                    // All the profile
                    if ($profile['entities_id'] < 0) {
                        return true;
                    }
                    // Restrict to entities
                    $entities = array($profile['entities_id']);
                    if ($profile['is_recursive']) {
                        $entities = getSonsOf('glpi_entities', $profile['entities_id']);
                    }
                    if (Session::haveAccessToOneOfEntities($entities, true)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }