|
@@ -0,0 +1,151 @@
|
|
|
+<?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;
|
|
|
+}
|