publication_date.install in Publication Date 8
Same filename and directory in other branches
Installation functions for the Publication Date module.
File
publication_date.installView 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
Name | Description |
---|---|
publication_date_install | Implements hook_install(). |
_publication_date_update_existing | Helper function to update the existing nodes on install. |