Search documentation of phoenix_kit

# PhoenixKit.Modules.Maintenance (phoenix_kit v1.7.87)

Copy Markdown View Source

Maintenance Mode module for PhoenixKit.

This module provides a system-wide maintenance mode that shows a maintenance page to all non-admin users while allowing admins and owners to access the site normally.

## Settings

The module uses the following settings stored in the database:

- `maintenance_module_enabled` - Boolean to enable/disable the module settings page (default: false)
- `maintenance_enabled` - Boolean to enable/disable maintenance mode (default: false)
- `maintenance_header` - Main heading text (default: "Maintenance Mode")
- `maintenance_subtext` - Descriptive subtext (default: "We'll be back soon")

## Usage

    # Check if module is enabled (settings page accessible)
    if PhoenixKit.Modules.Maintenance.module_enabled?() do
      # Show settings page
    end

    # Check if maintenance mode is enabled
    if PhoenixKit.Modules.Maintenance.enabled?() do
      # Show maintenance page to non-admin users
    end

    # Enable module (makes settings page accessible)
    PhoenixKit.Modules.Maintenance.enable_module()

    # Enable maintenance mode (shows maintenance page to users)
    PhoenixKit.Modules.Maintenance.enable_system()

    # Get module configuration
    config = PhoenixKit.Modules.Maintenance.get_config()
    # => %{module_enabled: true, enabled: true, header: "...", subtext: "..."}

## Summary

### Functions

disable_module()

Disables the Maintenance module (hides settings page).

disable_system()

Disables the Maintenance mode.

enable_module()

Enables the Maintenance module (makes settings page accessible).

enable_system()

Enables the Maintenance mode.

enabled?()

Checks if Maintenance mode is enabled.

get_config()

Gets the configuration for the Maintenance module.

get_header()

Gets the header text for the maintenance page.

get_subtext()

Gets the subtext for the maintenance page.

module_enabled?()

Checks if the Maintenance module is enabled (settings page accessible).

update_header(header)

Updates the header text for the maintenance page.

update_subtext(subtext)

Updates the subtext for the maintenance page.

## Functions

# disable_module()

Disables the Maintenance module (hides settings page).

Also automatically disables maintenance mode to prevent users from being locked out.

# disable_system()

Disables the Maintenance mode.

When disabled, all users can access the site normally.

# enable_module()

Enables the Maintenance module (makes settings page accessible).

# enable_system()

Enables the Maintenance mode.

When enabled, all non-admin users will see the maintenance page.

# enabled?()

Checks if Maintenance mode is enabled.

## Examples

    iex> PhoenixKit.Modules.Maintenance.enabled?()
    false

# get_config()

Gets the configuration for the Maintenance module.

Returns a map with:

- `module_enabled` - Boolean indicating if module settings page is accessible
- `enabled` - Boolean indicating if maintenance mode is enabled
- `header` - Main heading text
- `subtext` - Descriptive subtext

## Examples

    iex> PhoenixKit.Modules.Maintenance.get_config()
    %{
      module_enabled: false,
      enabled: false,
      header: "Maintenance Mode",
      subtext: "We'll be back soon..."
    }

# get_header()

Gets the header text for the maintenance page.

## Examples

    iex> PhoenixKit.Modules.Maintenance.get_header()
    "Maintenance Mode"

# get_subtext()

Gets the subtext for the maintenance page.

## Examples

    iex> PhoenixKit.Modules.Maintenance.get_subtext()
    "We'll be back soon..."

# module_enabled?()

Checks if the Maintenance module is enabled (settings page accessible).

## Examples

    iex> PhoenixKit.Modules.Maintenance.module_enabled?()
    false

# update_header(header)

Updates the header text for the maintenance page.

# update_subtext(subtext)

Updates the subtext for the maintenance page.