- <?php
- * @file
- * Install, update and uninstall functions for the nodeapi_example module.
- */
-
- * Implements hook_schema().
- *
- * @ingroup nodeapi_example
- */
- function node_hooks_example_schema() {
- $schema['node_hooks_example'] = array(
- 'description' => 'Stores information of extended content.',
- 'fields' => array(
- 'nid' => array(
- 'description' => 'The ID for the node to which the rating is applied.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'vid' => array(
- 'description' => 'The revision ID, as we are tracking rating with node revisions.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'rating' => array(
- 'description' => 'The node rating.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- ),
- ),
- 'primary key' => array('vid'),
- 'indexes' => array(
- 'nid' => array('nid'),
- ),
- );
-
- return $schema;
- }
-
- * Implements hook_install().
- *
- * We need to set a default node_hooks_example_node_type_<contentType> setting
- * to 0 for each available content type.
- *
- * We call node_type_get_types() to get a list of all the content types.
- *
- * @ingroup nodeapi_example
- */
- function node_hooks_example_install() {
- $config = config('node_hooks_example.settings');
- $node_types = array_keys(node_type_get_types());
- foreach($node_types as $type) {
- $config->set('node_hooks_example_node_type_' . $type, 0);
- }
- $config->save();
- }