SimpleHistory::getLoggersThatUserCanRead PHP Method

getLoggersThatUserCanRead() public method

Check which loggers a user has the right to read and return an array with all loggers they are allowed to read
public getLoggersThatUserCanRead ( integer $user_id = "", string $format = "array" ) : array
$user_id integer Id of user to get loggers for. Defaults to current user id.
$format string format to return loggers in. Default is array. Can also be "sql"
return array
    public function getLoggersThatUserCanRead($user_id = "", $format = "array")
    {
        $arr_loggers_user_can_view = array();
        if (!is_numeric($user_id)) {
            $user_id = get_current_user_id();
        }
        $loggers = $this->getInstantiatedLoggers();
        foreach ($loggers as $one_logger) {
            $logger_capability = $one_logger["instance"]->getCapability();
            //$arr_loggers_user_can_view = apply_filters("simple_history/loggers_user_can_read", $user_id, $arr_loggers_user_can_view);
            $user_can_read_logger = user_can($user_id, $logger_capability);
            $user_can_read_logger = apply_filters("simple_history/loggers_user_can_read/can_read_single_logger", $user_can_read_logger, $one_logger["instance"], $user_id);
            if ($user_can_read_logger) {
                $arr_loggers_user_can_view[] = $one_logger;
            }
        }
        /**
         * Fires before Simple History does it's init stuff
         *
         * @since 2.0
         *
         * @param array $arr_loggers_user_can_view Array with loggers that user $user_id can read
         * @param int user_id ID of user to check read capability for
         */
        $arr_loggers_user_can_view = apply_filters("simple_history/loggers_user_can_read", $arr_loggers_user_can_view, $user_id);
        // just return array with slugs in parenthesis suitable for sql-where
        if ("sql" == $format) {
            $str_return = "(";
            if (sizeof($arr_loggers_user_can_view)) {
                foreach ($arr_loggers_user_can_view as $one_logger) {
                    $str_return .= sprintf('"%1$s", ', esc_sql($one_logger["instance"]->slug));
                }
                $str_return = rtrim($str_return, " ,");
            } else {
                // user was not allowed to read any loggers, return in (NULL) to return nothing
                $str_return .= 'NULL';
            }
            $str_return .= ")";
            return $str_return;
        }
        return $arr_loggers_user_can_view;
    }
SimpleHistory