You are here

publication_date.install in Publication Date 8

Installation functions for the Publication Date module.

File

publication_date.install
View source
<?php

/**
 * @file
 * Installation functions for the Publication Date module.
 */

/**
 * Implements hook_install().
 */
function publication_date_install() {

  // Set publication dates for existing nodes.
  _publication_date_update_existing();

  // This module must be called after some other modules (i.e. Scheduler).
  module_set_weight('publication_date', 99);
}

/**
 * Helper function to update the existing nodes on install.
 *
 * We can not know the exact date of publication, so $node->published_at will
 * initially contain the creation date for already publisned nodes.
 */
function _publication_date_update_existing() {

  // @todo: Convert to entity query.
  return;
  $query = db_select('node');
  $query
    ->addField('node', 'nid');
  $query
    ->addField('node', 'created', 'published_at');
  $nids = $query
    ->condition('status', 1);
  db_insert('publication_date')
    ->from($nids)
    ->execute();
}

Functions

Namesort descending Description
publication_date_install Implements hook_install().
_publication_date_update_existing Helper function to update the existing nodes on install.