|  | <?php | 
        
          |  |  | 
        
          |  | /** | 
        
          |  | * Implementation of hook_help(). | 
        
          |  | */ | 
        
          |  | function bulk_update_author_help($path, $arg) { | 
        
          |  | switch ($path) { | 
        
          |  | case 'admin/help#bulk_update_author': | 
        
          |  | $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>'; | 
        
          |  | $output .= '<p>Documentation of the hook: <a href="https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_node_operations/7">hook_node_operations()</a>'; | 
        
          |  | return $output; | 
        
          |  | } | 
        
          |  | } | 
        
          |  | /** | 
        
          |  | * Implementation of hook_node_operations(). | 
        
          |  | * Add siteowner users to list to easily change author to. | 
        
          |  | */ | 
        
          |  | function the_aim_custom_node_operations() { | 
        
          |  | // Get the correct role data | 
        
          |  | $role = user_role_load_by_name('siteowners'); | 
        
          |  | // Get siteowner users | 
        
          |  | $query = db_select('users_roles', 'ur'); | 
        
          |  | $query->innerJoin('users', 'u', 'ur.uid = u.uid AND ur.rid = :rid', array(':rid' => $role->rid)); | 
        
          |  | $results = $query | 
        
          |  | ->fields('ur', array('uid')) | 
        
          |  | ->fields('u', array('name')) | 
        
          |  | ->execute() | 
        
          |  | ->fetchAllAssoc('uid'); | 
        
          |  | $operations = array(); | 
        
          |  |  | 
        
          |  | foreach($results as $uid => $result) { | 
        
          |  | $operations['author_update_so_' . $result->uid] = array( | 
        
          |  | 'label' => t('Change author to !name', array('!name' => $result->name)), | 
        
          |  | 'callback' => 'node_mass_update', | 
        
          |  | 'callback arguments' => array('updates' => array('uid' => $result->uid)), | 
        
          |  | ); | 
        
          |  | } | 
        
          |  |  | 
        
          |  | return $operations; | 
        
          |  | } |