You are here

function _node_gallery_update_group_settings in Node Gallery 6.3

Updates the organic group settings of all gallery images when the settings in the gallery changed.

Parameters

object $node: A reference to a gallery node object

$status: The new publish status to set on the node

1 call to _node_gallery_update_group_settings()
node_gallery_nodeapi in ./node_gallery.module
Implements hook_nodeapi().

File

./node_gallery.module, line 871
Node gallery module file.

Code

function _node_gallery_update_group_settings(&$node, $og_settings) {
  $gid = $node->nid;
  $imagenids = node_gallery_get_image_nids($gid, FALSE, FALSE);

  // Split our operations into NODE_GALLERY_BATCH_CHUNK_SIZE a time
  $node_updates = array_chunk($imagenids, NODE_GALLERY_BATCH_CHUNK_SIZE);
  array_walk_recursive($node_updates, create_function('&$v,$k,$og_settings', '$v = array(\'nid\' => $v); $v = (object)array_merge($v, $og_settings);'), $og_settings);
  foreach ($node_updates as $node_update) {
    $operations[] = array(
      'node_gallery_batch_node_save',
      array(
        $node_update,
      ),
    );
  }
  if (!empty($operations)) {
    $batch = array(
      'operations' => $operations,
      'finished' => 'node_gallery_image_process_finished',
      'title' => t('Processing gallery organic group settings update.'),
      'init_message' => t('Gallery organic group settings update is cascading to images.'),
      'progress_message' => t('Processing organic group settings of images.'),
      'error_message' => t('Encountered an error while changing the organic group settings of the gallery images.'),
    );
    batch_set($batch);
    node_gallery_clear_gallery_caches($gid);
  }
}