I am/was in need of an action to mark all nodes as read (for a forum). I found some D6 code and modified to suit D7. I have made a custom module that makes the necessary action, but it would probably be a good feature to implement to VBO. The code for my stand-alone module is below, in case this never makes it into VBO (and this is probably the module where people will look for such an action). Zip of module also attached.

mark_read.info

name = Mark Read
description = Creates an action to mark nodes as read, suitable for Views Bulk Operations.
core = 7.x

mark_read.install

<?php

/**
 * @file
 * Installation and update functions.
 */

/**
 * Implements hook_uninstall().
 */
function mark_read_uninstall() {
  // Remove Mark Read actuin that is now orphaned.
  actions_synchronize(TRUE);
}

mark_read.module

<?php
/**
 * Implements hook_action_info().
 */
function mark_read_action_info() {
  return array(
    'mark_read_node_action' => array(
      'label' => t('Mark as read'),
      'type' => 'node',
      'configurable' => FALSE,
      'triggers' => array('any'),
      ),
  );
}

/**
* Callback for mark_read_action_info
*/
function mark_read_node_action($object, $context = array()) {
  if(isset($object->nid)) {
    node_tag_new($object);
  } else if(isset($context['nid'])) {
    node_tag_new($context);
  }
}
CommentFileSizeAuthor
mark_read.zip1.14 KBneRok

Comments

sw3b’s picture

Version: 7.x-3.1 » 7.x-3.3
Status: Active » Reviewed & tested by the community

This is a great add on and it work.

joelpittet’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
Status: Reviewed & tested by the community » Needs work

Could this be created as a patch? and there are some coding standards cleanups that could be done. Look at the spaces around control structures and comments.
https://www.drupal.org/coding-standards