smartqueue.install in Nodequeue 6.2
Same filename and directory in other branches
Install, update and uninstall functions for the smartqueue module.
File
smartqueue.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the smartqueue module.
*/
/**
* Implementation of hook_schema().
*/
function smartqueue_schema() {
$schema['smartqueue'] = array(
'description' => 'Table for smartqueues, storing global information for each queue.',
'fields' => array(
'qid' => array(
'description' => 'The primary identifier for a queue.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'use_parents' => array(
'description' => "Whether a queue is to use the terms' parents when displaying the queue selection.",
'type' => 'int',
'size' => 'tiny',
'default' => 0,
),
),
'primary key' => array(
'qid',
),
);
return $schema;
}
/**
* Implementation of hook_install().
*/
function smartqueue_install() {
drupal_install_schema('smartqueue');
}
/**
* Implementation of hook_uninstall().
*/
function smartqueue_uninstall() {
drupal_uninstall_schema('smartqueue');
}
/**
* Implementation of hook_update_N().
*
* Adds the smartqueue table.
*/
function smartqueue_update_6003() {
$ret = array();
// Don't use hook_schema for database updates per http://drupal.org/node/150220.
// It's possible that users who installed the 2.7 or 2.8 versions of
// smartqueue will already have this table.
if (!db_table_exists('smartqueue')) {
$schema = array(
'description' => 'Table for smartqueues, storing global information for each queue.',
'fields' => array(
'qid' => array(
'description' => 'The primary identifier for a queue.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'use_parents' => array(
'description' => "Whether a queue is to use the terms' parents when displaying the queue selection.",
'type' => 'int',
'size' => 'tiny',
'default' => 0,
),
),
'primary key' => array(
'qid',
),
);
db_create_table($ret, 'smartqueue', $schema);
}
$result = db_query('SELECT q.qid FROM {nodequeue_queue} q LEFT JOIN {smartqueue} s ON q.qid = s.qid WHERE s.qid IS NULL');
while ($queue = db_fetch_object($result)) {
$ret[] = update_sql('INSERT INTO {smartqueue} (qid) VALUES (' . $queue->qid . ')');
}
return $ret;
}
/**
* Clean-up leftovers from the {smartqueue} table.
*/
function smartqueue_update_6004() {
db_query('DELETE FROM {smartqueue} WHERE `qid` NOT IN (SELECT qid FROM {nodequeue_queue})');
return array();
}
Functions
Name![]() |
Description |
---|---|
smartqueue_install | Implementation of hook_install(). |
smartqueue_schema | Implementation of hook_schema(). |
smartqueue_uninstall | Implementation of hook_uninstall(). |
smartqueue_update_6003 | Implementation of hook_update_N(). |
smartqueue_update_6004 | Clean-up leftovers from the {smartqueue} table. |