I would like to add in my own modifications for locking a specific node to be viewable by only a few authenticated users, and have the options toggled from within the page where $form_id=='workflow_edit_form' as what this module is doing to $form_id=='workstate_add_form'?

I am having difficulty understanding how the options are slipped into $form and how I can add my own options to the database.

Help, please?

Comments

infojunkie’s picture

If I understand our question correctly, I think the Workflow Access module provides this feature. Workflow Fields operates on individual fields, not whole nodes.

Jkello’s picture

Is it possible for Workflow_fields to include the feature of building access to nodes on the basis of users stated in the user reference field?

This would be a good addition to the present module which only operates on individual fields and not the node itself.

Jkello’s picture

Category: support » feature
Noktha’s picture

I can code but I am still confused with Drupal's architecture. How can I implement such a feature as discussed above?

I have studied the module code but is unable to decipher how to insert the checkbox into the form properly. I have slipped in my own code but it is not displaying properly.

The following are the functions that I have modified in workflow_access.module with the rest remaining the same. I hope you will not consider it a sacrilege.

/**
 * Implementation of hook_form_alter().
 * Hook on both any CCK node form and on the workflow state form.
 *
 * @param object &$node
 * @return array
 */
function workflow_fields_form_alter(&$form, $form_state, $form_id) {
  echo "<!-- $form_id -->";
  if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
    workflow_fields_node_form_alter($form, $form_state, $form_id);
  }
  elseif ('workflow_state_add_form' == $form_id) {
    workflow_fields_state_form_alter($form, $form_state, $form_id);
  }
  elseif ('workflow_edit_form' == $form_id) {
    workflow_edit_form_alter($form, $form_state, $form_id);
  }
}

/**
 * Alter the workflow edit form.
 * I will find out what to put in here soon.
 */
function workflow_edit_form_alter(&$form, $form_state, $form_id) {
	$form['tab']['tab_roles']['#options']['TO'] = 'TestOption';
	$form['transitions'][1][2]['TO']=array(
		'#type' => 'checkbox',
		'#title' => 'TestOption',
		'#default_value' => 1
	);
	$form['transitions'][1][3]['TO']=$form['transitions'][1][2]['TO'];
	$form['transitions'][2][3]['TO']=$form['transitions'][1][2]['TO'];
	$form['transitions'][3][2]['TO']=$form['transitions'][1][2]['TO'];
	//unset($form['transitions']);
	echo "<!--\n";
	print_r($form);
	echo "-->";
  
}

Unfortunately the checkboxes are not displaying correctly at all. Not to mention they do not feed back to anything for storage. However, I would just like to learn how to modify the form first before messing around with the database.

Thanks.

infojunkie’s picture

Status: Active » Closed (won't fix)

@Noktha:
There is a definite learning curve for Drupal programming. I suggest reading the excellent book "Pro Drupal Development", second edition to get acquainted with Form API programming. I'm afraid I can't (don't have time nor willingness to) help you here on these general questions.

But I do reiterate that the functionality you are talking about does *not* belong to Workflow Fields. When you produce the code that does what you want, it would be best IMO if you packaged it in your own, new module. Same goes for JK_Drupal's suggestion.