thierry-b
12/16/2014 - 8:39 AM

Node operation to change the content author to siteowner

Node operation to change the content author to siteowner

name = "Change author to siteowner"
description = "Provides a node operation to change the content author to siteowner"
package = "the AIM"
core = 7.x
<?php
 
/**
 * Implementation of hook_help().
 */
function the_aim_author_change_help($path, $arg) {
 switch ($path) {
 case 'admin/help#the_aim_author_change':
   $output = '<h3>' . t('Add extra bulk operation for content') . '</h3>';
   $output .= '<p>Unpublished node created by admin are not accessable for siteowners.<br />Therefore we must change the author of the nodes to siteowner. This module adds the extra bulk update action...</p>';
   $output .= '<ul>';
   $output .= '<li>Activate the <a href="/admin/modules">module</a></li>';
   $output .= '<li><a href="/admin/config/development/performance">Clear cache</a></li>';
   $output .= '<li>Bulk update your <a href="/admin/content">nodes</a></li>';
   $output .= '<li>Don\'t forget to desactivate the <a href="/admin/modules">module</a> when this magnificent piece of code did it\'s work</li>';
   $output .= '</ul>';
 return $output;
   }
 }
 
/**
 * Implementation of hook_node_operations().
 */
function the_aim_author_change_node_operations() {
  $operations = array(
    'author_update' => array(
      'label' => t('Change author to siteowner'),
      'callback' => 'node_mass_update',
      'callback arguments' => array('updates' => array('uid' => 3)),
    ),
  );
  return $operations;
}