It is pretty easy to get profiles as nodes in Drupal. The trick is in the combination of the
workflow,
CCK,
actions and possibly the
views modules.
First, use CCK to create a profile node type. Add what ever fields you want. This is the easy part.
Now, setup your workflow. In my case I created two states; 'moderation' and 'accepted'. I needed my profiles to be moderated. Authors can only only progress from 'creation' to 'moderation'. An admin role can progress the node to 'accepted'. Attach your new workflow to your profile node type.
At this point, I should bring up a slight annoyance with the workflow module. If there is only one possible state change, the workflow fields are still visible on the node edit form. There is a
patch to fix this if you want. It works for me.
Now that you have your profile node and workflow states, it is time to setup actions. For my setup, I set nodes as moderated when going from 'creation' to 'moderation', and cleared modertion when going from 'moderation' to 'accepted'.
This is great and all, but there is nothing preventing a user from creating more than one profile. This can be fixed with a small custom module that just adds a new action.
dummy_actions/dummy_actions.module
<?php
// hook_help
function dummy_actions_help($section) {
switch ($section) {
case 'admin/modules#description':
// This description is shown in the listing at admin/modules.
return t('Provides custom user actions.');
}
}
function action_limit_nodetypes_peruser($op, $edit = array(), $node) {
switch ($op) {
case 'metadata':
return array(
'description' => t('Limit number of a node type per user to 1'),
'type' => t('Node'),
'batchable' => true,
'configurable' => false,
);
case 'do':
db_query("UPDATE {node} SET status=0 WHERE nid!=%d AND uid=%d AND type='%s'", $node->nid, $node->uid, $node->type);
break;
case 'form':
return '';
case 'validate':
return TRUE;
case 'submit':
return '';
}
}
I attached this new action to the transition from 'modertion' to 'accepted'. Now, when a profile is 'accepted', previous profile nodes for the same user will be unpublished.
The views module can be used to setup lists of profiles and profiles awaiting moderation. It's all up to you.
TODO:
- Need to investigate revisions instead of whole new nodes