|
@@ -1,13 +1,163 @@
|
|
|
<?php
|
|
|
+
|
|
|
/**
|
|
|
* @file
|
|
|
* Workflow - New Generation
|
|
|
*
|
|
|
* - States are entities
|
|
|
* - Worfklows are the bundle entities of states
|
|
|
- * - Transitions are specific fields from state to role_id+state
|
|
|
+ * - Transitions are fields on states, storing a (rid, sid) pair per item
|
|
|
* - Any entity type can be subject to a workflow: association is represented by
|
|
|
- * an entityreference field with specific widget/formatter.
|
|
|
+ * an entityreference field whose widget uses a specific view to list the
|
|
|
+ * relevant states
|
|
|
+ * - Workflow access is handled by field access using the permission associated
|
|
|
+ * with a state, one "view" or "edit" permission per state entity
|
|
|
+ *
|
|
|
+ * URL structure admin/structure/wing/...
|
|
|
+ * /: dashboard
|
|
|
+ * /settings: module settings
|
|
|
+ * /add: workflow creation form
|
|
|
+ * /workflow[/list]: list of workflows
|
|
|
+ * /workflow/add: state creation form
|
|
|
+ * /workflow/<wname>[/info]: info on workflow with list of states
|
|
|
+ * /workflow/<wname>/edit|clone|delete|export: workflow operations form
|
|
|
+ * /workflow/<wname>/fields: field UI for workflow as state bundle
|
|
|
+ * /workflow/<wname>/fields: view modes for workflow as state bundle
|
|
|
+ * /state[/list]: list of states
|
|
|
+ * /state/<sname>[/info]: info on state, with list of previous/next states
|
|
|
+ * and list of entities in state
|
|
|
+ * /state/<sname>/edit|clone|delete|export
|
|
|
+ * state operations form. Main point of interest is the transitions subform
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * Implements hook_entity_info().
|
|
|
+ */
|
|
|
+function wing_entity_info() {
|
|
|
+ $ret = array();
|
|
|
+ $ret['wing_workflow'] = array(
|
|
|
+ 'access callback' => 'wing_workflow_access',
|
|
|
+ 'admin ui' => array(
|
|
|
+ 'controller class' => 'WingWorkflowUIController',
|
|
|
+ // 'file' => '',
|
|
|
+ // 'file path' => '',
|
|
|
+ 'menu wildcard' => '%entity_object',
|
|
|
+ 'path' => 'admin/content/wing/workflow'
|
|
|
+ ),
|
|
|
+ 'base table' => 'wing_workflow',
|
|
|
+ 'bundle of' => 'wing_state',
|
|
|
+ 'controller class' => 'WingWorkflowController',
|
|
|
+ 'entity class' => 'WingWorkflow',
|
|
|
+ 'entity keys' => array(
|
|
|
+ 'id' => 'wid',
|
|
|
+ 'label' => 'title',
|
|
|
+ 'module' => 'module',
|
|
|
+ 'name' => 'name',
|
|
|
+ 'status' => 'status',
|
|
|
+ ),
|
|
|
+ 'export' => array(
|
|
|
+ 'default hook' => 'default_wing_workflows',
|
|
|
+ ),
|
|
|
+ 'exportable' => TRUE,
|
|
|
+ 'features controller class' => 'WingWorkflowFeaturesController',
|
|
|
+ 'fieldable' => FALSE,
|
|
|
+ 'label' => t('Wing: Workflow'),
|
|
|
+ 'label callback' => 'entity_class_label',
|
|
|
+ 'load hook' => 'wing_workflow_load', // Enable hook_workflow_load().
|
|
|
+ 'module' => 'wing',
|
|
|
+ 'uri callback' => 'entity_class_uri',
|
|
|
+ 'view modes' => array(
|
|
|
+ 'full' => array(
|
|
|
+ 'label' => t('Full'),
|
|
|
+ 'custom settings' => FALSE,
|
|
|
+ ),
|
|
|
+ 'summary' => array(
|
|
|
+ 'label' => t('Summary'),
|
|
|
+ 'custom settings' => FALSE,
|
|
|
+ ),
|
|
|
+ 'simple' => array(
|
|
|
+ 'label' => t('Simple'),
|
|
|
+ 'custom settings' => FALSE,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 'views controller class' => 'WingWorkflowViewsController',
|
|
|
+ );
|
|
|
+
|
|
|
+ $ret['wing_state'] = array(
|
|
|
+ 'access callback' => 'wing_state_access',
|
|
|
+ 'admin ui' => array(
|
|
|
+ 'controller class' => 'WingStateUIController',
|
|
|
+ // 'file' => '',
|
|
|
+ // 'file path' => '',
|
|
|
+ 'menu wildcard' => '%entity_object',
|
|
|
+ 'path' => 'admin/content/wing/state/%entity_object'
|
|
|
+ ),
|
|
|
+ 'base table' => 'wing_state',
|
|
|
+ 'bundle keys' => array('bundle' => 'workflow'),
|
|
|
+ 'bundles' => array(),
|
|
|
+ 'controller class' => 'WingStateController',
|
|
|
+ 'entity class' => 'WingState',
|
|
|
+ 'entity keys' => array(
|
|
|
+ 'id' => 'sid',
|
|
|
+ 'bundle' => 'workflow',
|
|
|
+ 'label' => 'title',
|
|
|
+ 'module' => 'module',
|
|
|
+ 'name' => 'name',
|
|
|
+ 'status' => 'status',
|
|
|
+ ),
|
|
|
+ 'export' => array(
|
|
|
+ 'default_hook' => 'default_wing_states',
|
|
|
+ ),
|
|
|
+ 'exportable' => TRUE,
|
|
|
+ 'features controller class' => 'WingStateFeaturesController',
|
|
|
+ 'fieldable' => TRUE,
|
|
|
+ 'label' => t('Wing: State'),
|
|
|
+ 'label callback' => 'entity_class_label',
|
|
|
+ 'load hook' => 'wing_state_load',
|
|
|
+ 'module' => 'wing',
|
|
|
+ 'uri callback' => 'entity_class_uri',
|
|
|
+ 'view modes' => array(
|
|
|
+ 'full' => array(
|
|
|
+ 'label' => t('Full'),
|
|
|
+ 'custom settings' => FALSE,
|
|
|
+ ),
|
|
|
+ 'summary' => array(
|
|
|
+ 'label' => t('Summary'),
|
|
|
+ 'custom settings' => FALSE,
|
|
|
+ ),
|
|
|
+ 'simple' => array(
|
|
|
+ 'label' => t('Simple'),
|
|
|
+ 'custom settings' => FALSE,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 'views controller class' => 'WingStateViewsController',
|
|
|
+ );
|
|
|
+
|
|
|
+ // Add bundle info but bypass entity_load() as we cannot use it here.
|
|
|
+ $workflows = db_select('wing_workflow', 'ww')
|
|
|
+ ->fields('ww')
|
|
|
+ ->execute()
|
|
|
+ ->fetchAllAssoc('name');
|
|
|
+
|
|
|
+ foreach ($workflows as $workflow_name => $workflow) {
|
|
|
+ $ret['wing_state']['bundles'][$workflow_name] = array(
|
|
|
+ 'label' => $workflow->title,
|
|
|
+ 'admin' => array(
|
|
|
+ 'path' => 'admin/content/wing/workflow/%entity_object',
|
|
|
+ 'real path' => 'admin/content/wing/workflow/' . $workflow_name,
|
|
|
+ 'bundle argument' => 4,
|
|
|
+ 'access arguments' => array('administer wing'),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Implements hook_field_info().
|
|
|
+ *
|
|
|
+ * Define "wing_transition" as a UI-less field.
|
|
|
*/
|
|
|
function wing_field_info() {
|
|
|
$ret = array(
|
|
@@ -27,6 +177,9 @@ dsm($ret);
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements hook_field_widget_info().
|
|
|
+ */
|
|
|
function wing_field_widget_info() {
|
|
|
$ret = array(
|
|
|
'text_textfield' => array(
|
|
@@ -51,3 +204,75 @@ function wing_field_widget_info_alter(&$info) {
|
|
|
$info['text_textfield']['field types'][] = 'wing_transition';
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Implements hook_menu().
|
|
|
+ */
|
|
|
+function wing_menu() {
|
|
|
+ $items = array();
|
|
|
+ $items['admin/content/wing'] = array(
|
|
|
+ 'title' => 'Wing',
|
|
|
+ 'access arguments' => array('administer wing'),
|
|
|
+ 'page callback' => 'wing_overview',
|
|
|
+ 'file' => 'wing.pages.inc',
|
|
|
+ );
|
|
|
+ $items['admin/content/wing/info'] = array(
|
|
|
+ 'title' => 'Info',
|
|
|
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
|
|
|
+ );
|
|
|
+ $items['admin/content/wing/settings'] = array(
|
|
|
+ 'title' => 'Settings',
|
|
|
+ 'type' => MENU_LOCAL_TASK,
|
|
|
+ 'page callback' => 'drupal_get_form',
|
|
|
+ 'page arguments' => array('wing_settings_form'),
|
|
|
+ 'file' => 'wing.admin.inc',
|
|
|
+ 'access arguments' => array('administer wing'),
|
|
|
+ );
|
|
|
+ return $items;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Implements hook_permission().
|
|
|
+ */
|
|
|
+function wing_permission() {
|
|
|
+ $ret = array(
|
|
|
+ 'administer wing' => array(
|
|
|
+ 'title' => t('Administer Wing'),
|
|
|
+ 'description' => t('Perform administration tasks for Wing.'),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Entity access callback for wing_state.
|
|
|
+ *
|
|
|
+ * @param string $op
|
|
|
+ * 'create', 'update', 'delete' or 'view'
|
|
|
+ * @param WingState $entity
|
|
|
+ * @param stdClass $account
|
|
|
+ * @param string $entity_type
|
|
|
+ *
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
+function wing_state_access($op, $entity, $account, $entity_type) {
|
|
|
+ dsm(get_defined_vars(), __FUNCTION__);
|
|
|
+ return TRUE;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Entity access callback for wing_workflow.
|
|
|
+ *
|
|
|
+ * @param string $op
|
|
|
+ * 'create', 'update', 'delete' or 'view'
|
|
|
+ * @param WingWorkflow $entity
|
|
|
+ * @param stdClass $account
|
|
|
+ * @param string $entity_type
|
|
|
+ *
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
+function wing_workflow_access($op, $entity, $account, $entity_type) {
|
|
|
+ dsm(get_defined_vars(), __FUNCTION__);
|
|
|
+ return TRUE;
|
|
|
+}
|