You are here

function backup_migrate_item::all_items in Backup and Migrate 6.3

Same name and namespace in other branches
  1. 8.2 includes/crud.inc \backup_migrate_item::all_items()
  2. 8.3 includes/crud.inc \backup_migrate_item::all_items()
  3. 6.2 includes/crud.inc \backup_migrate_item::all_items()
  4. 7.3 includes/crud.inc \backup_migrate_item::all_items()
  5. 7.2 includes/crud.inc \backup_migrate_item::all_items()

Get all of the given items.

3 calls to backup_migrate_item::all_items()
backup_migrate_item::get_list in includes/crud.inc
Get a table of all items of this type.
backup_migrate_item::item in includes/crud.inc
A particular item.
backup_migrate_item::item_exists in includes/crud.inc
A particular item.

File

includes/crud.inc, line 905
CRUD functions for backup and migrate types (schedules, profiles etc.).

Class

backup_migrate_item
A base class for items which can be stored in the database, listed, edited, deleted etc.

Code

function all_items() {
  static $cache = array();

  // Allow other modules to declare destinations programatically.
  $items = module_invoke_all($this->db_table);

  // Get CTools exported versions.
  if (function_exists('ctools_include')) {
    ctools_include('export');
    $defaults = ctools_export_load_object($this->db_table);
    foreach ($defaults as $info) {
      $info = (array) $info;
      if (!empty($info) && ($item = $this
        ->create($info))) {
        $items[$item
          ->get_id()] = $item;
      }
    }
  }

  // Get any items stored as a variable. This allows destinations to be defined in settings.php
  $defaults = (array) variable_get($this->db_table . '_defaults', array());
  foreach ($defaults as $info) {
    if (is_array($info) && ($item = $this
      ->create($info))) {
      $items[$item
        ->get_id()] = $item;
    }
  }

  // Get the items from the db.
  $result = db_query("SELECT * FROM {{$this->db_table}}");
  while ($info = db_fetch_array($result)) {
    $info = $this
      ->decode_db_row($info);
    if ($item = $this
      ->create($info)) {
      $item->storage = empty($items[$item
        ->get_id()]) ? BACKUP_MIGRATE_STORAGE_DB : BACKUP_MIGRATE_STORAGE_OVERRIDEN;
      $items[$item
        ->get_id()] = $item;
    }
  }

  // Allow other modules to alter the items. This should maybe be before the db override code above
  // but then the filters are not able to set defaults for missing values. Other modules should just
  // be careful not to overwrite the user's UI changes in an unexpected way.
  drupal_alter($this->db_table, $items);
  return $items;
}