123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- /**
- * @file
- * Install file for W.NG
- */
- /**
- * Helper for entity exportability.
- *
- * May not use entity_exportable_schema_fields() directly.
- *
- * @see entity_exportable_schema_fields()
- */
- function _wing_exportable_schema_fields($entity) {
- $t = get_t();
- $arg = array('@entity' => $entity);
- $ret = array(
- 'machine_name' => array(
- 'description' => $t('The machine name of the @entity.', $arg),
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- ),
- 'title' => array(
- 'description' => $t('The human name of the @entity.', $arg),
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- ),
- 'created' => array(
- 'description' => $t('The Unix timestamp when the @entity was created.', $arg),
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'changed' => array(
- 'description' => t('The Unix timestamp when the @entity was most recently saved.', $arg),
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'status' => array(
- 'description' => $t('The exportable status of the @entity.', $arg),
- 'type' => 'int',
- 'not null' => TRUE,
- // Set the default to ENTITY_CUSTOM without using the constant as it is
- // not safe to use it at this point.
- 'default' => 0x01,
- 'size' => 'tiny',
- ),
- 'module' => array(
- 'description' => $t('The name of the providing module if the @entity has been defined in code.', $arg),
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- ),
- );
- return $ret;
- }
- function wing_field_schema($field) {
- $schema = array(
- 'columns' => array(
- 'rid' => array(
- 'description' => 'The id of the role performing the transition.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'sid' => array(
- 'description' => 'The id of the state at the end of the transition.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- ),
- 'indexes' => array(
- 'target_id' => array('rid', 'sid'),
- ),
- 'foreign keys' => array(
- 'role' => array(
- 'table' => 'role',
- 'columns' => array('rid' => 'rid'),
- ),
- 'next_state' => array(
- 'table' => 'wing_state',
- 'columns' => array('sid' => 'sid'),
- ),
- ),
- );
- return $schema;
- }
- /**
- * Implements hook_schema().
- *
- * - wing_state
- * - wing_workflow
- */
- function wing_schema() {
- $schema = array(
- 'wing_state' => array(
- 'description' => 'The base table for Wing State entities',
- 'fields' => array(
- 'sid' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'workflow' => array(
- 'description' => 'The {wing_workflow}.machine_name of this state.',
- 'type' => 'varchar',
- 'length' => 32,
- 'not null' => TRUE,
- 'default' => '',
- ),
- ) + _wing_exportable_schema_fields('wing_state'),
- 'primary key' => array('sid'),
- 'indexes' => array(
- 'workflow' => array('workflow'),
- ),
- 'unique keys' => array('machine_name' => array('machine_name')),
- 'foreign keys' => array(
- 'workflow' => array(
- 'table' => 'wing_workflow',
- 'columns' => array('workflow' => 'wid'),
- ),
- ),
- ),
- 'wing_workflow' => array(
- 'description' => 'The base table for Wing Workflow entities',
- 'fields' => array(
- 'wid' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- ) + _wing_exportable_schema_fields('wing_workflow'),
- 'primary key' => array('wid'),
- 'unique keys' => array('machine_name' => array('machine_name')),
- ),
- );
- return $schema;
- }
- /**
- * Implements hook_uninstall().
- *
- * @see entity_test_uninstall() {
- */
- function wing_uninstall() {
- // FIXME: provide correct values.
- $wing_state_types = array();
- foreach ($wing_state_types as $name => $type) {
- field_attach_delete_bundle('entity_test', $name);
- }
- }
|