Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Description:
Creates a new node revision upon flagging a node with the Flag module and displays flag type (name + flag/unflagged) in revision log. Benefit: Rules module installation no longer required for that specific purpose.
Requires:
- Drupal 6.x
- Revisions enabled
- Flag module 6.x-1.x
Usage
Create a new .module file -- like flag_revision.module and the respective flag_revision.info file.
Code
Put this in your just created flag_revision.module file.
<?php
function flag_revision_action_info()
{
$info['flag_revision_create_revision_action'] = array(
'type' => 'node',
'description' => t('Create new revision'),
'configurable' => FALSE,
'behavior' => array('changes_node_property'),
'hooks' => array(
'flag' => TRUE,
),
);
return $info;
}
function flag_revision_create_revision_action($object, $context)
{
$object->revision = 1;
$flag = flag_get_flag($context['flag-action']->flag);
$object->log = t((($context['flag-action']->action == 'flag')?'Flagged - @flag_title':'Unflagged - @flag_title'),array('@flag_title' => $flag->get_title()));
}
The end
Save, upload to modules folder and active it. The "Create new revision" action can now be associated with a flag from -> Flags ->Actions.