The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Drupal::Admin - screen scraping Perl API to some Drupal admin functions

SYNOPSIS

  use Drupal::Admin;

  my $admin = new Drupal::Admin(baseurl => 'http://localhost');

  $admin->login(user => 'admin', password => 'lukeskywalker')

  $admin->offline;
  $admin->online;

  $admin->update;

  $admin->runcron;

  my $statusreport = $admin->status;

  my $status = $admin->enabletheme('garland, 0');
  my $theme = $admin->defaulttheme('bluemarine');

NOTES

Most of the methods in this class depend on English strings from the pages' value fields, because WWW:Mechanize doesn't use id fields as selectors. This module will most likely not work for sites that aren't in English.

METHODS

new

Constructor takes required baseurl parameter (without a terminating slash).

login

Perform login to the site. Takes two required parameters, user and password. The user must have administrator privileges within drupal. Calls die() on error.

offline

Take the site offline.

online

Bring the site online.

update

Runs the update.php script. Calls die() on error.

status

Returns a parsed status report. The returned data structure is of the form:

  $report = {
             info => [],
             ok => [],
             warning => [],
             error => []
            };

The elements of the arrays are Drupal::Admin::Status objects, which have the following read-only accessor methods:

type

info, ok, warning or error

title

Name of the status item

status

Status message

comment

Additional comment (optional; warnings and errors usually have one)

runcron

Run the cron script once.

enabletheme

Enable/disable a theme. Takes theme name argument (as used in the form; this is generally a lowercase version of the user visible label), and optional boolean status argument. Returns current status.

defaulttheme

Get/set default theme. Takes optional theme name argument. Returns current default theme. Note that setting a theme as default will automatically enable it.

modulestate

Returns a Drupal::Admin::ModuleState object. See documentation in that module.