Hi,

I am currently use node gallery with organic groups, and find that,

After deleting a gallery which was posted within an organic group, the user will be led to the front page of the site, rather than the front page of the group.

Any ideas how to fix ?

thanks.

Comments

foredoc’s picture

Category: feature » support
Status: Active » Needs review
Issue tags: -Organic Groups integration

solution:

Use batch_process() to redirect the page after batch_set(...):

function _node_gallery_delete(&$node) {

  if (in_array($node->type, (array)node_gallery_get_types('gallery'))) {
    $gid = $node->nid;
    $imagenids = node_gallery_get_image_nids($gid, FALSE, FALSE, TRUE);
    $total = count($imagenids);
    // Split our operations into X deletes at a time
    while (count($imagenids) > 0) {
      if (count($imagenids) >= NODE_GALLERY_BATCH_DELETE) {
        $nids = array_splice($imagenids, 0, 10);
      }
      else {
        $nids = $imagenids;
        unset($imagenids);
      }
      $operations[] = array('node_gallery_image_delete_process', array($nids));
    }
    if (!empty($operations)) {
      $batch = array(
        'operations' => $operations,
        'finished' => 'node_gallery_image_process_finished',
        'title' => t('Processing Gallery Delete.'),
        'init_message' => t('Gallery deletion is cascading to images.'),
        'progress_message' => t('Processing image deletions.'),
        'error_message' => t('Gallery deletion has encountered an error.'),
      );
      
      batch_set($batch);
      //------------------------add the following--------------------------------
			if( module_exists('og') ){
				$group = og_get_group_context();
				if( isset($group->nid) )
					batch_process('node/'.$group->nid);
			}
     //--------------------------------end-----------------------------------------
    }
    node_gallery_delete_gallery($node);
  }
  if (in_array($node->type, (array)node_gallery_get_types('image'))) {
    $gid = $node->gid;
    node_gallery_delete_image($node);
  }
  node_gallery_clear_gallery_caches($gid);
}
dddave’s picture

Category: support » feature

Redirecting to frontpage after node deletion is the default drupal behavior. Changing this within the context of OG might make sense but is a feature request. Codewise I cannot review your idea but if it works a "real" patch might drastically increase the chances of inclusion.

dddave’s picture

Adding tag

foredoc’s picture

Category: support » feature
Status: Needs review » Active
Issue tags: +Organic Groups integration

the only modification is between:

//-----------------------add following----------------------------

and

//---------------------------end-----------------------------------

And I will learn to make a patch first

foredoc’s picture

StatusFileSize
new452 bytes

Please find attached the patch,

It redirects the user to group node page, after deleting a gallery within that group.

dddave’s picture

Status: Active » Needs review

;)

I am not using OG so I cannot test it. When justintime is back he might be interested to here if you a re using this patch successfully in production.

foredoc’s picture

@justintime, could you please take a look at the patch.

Thanks.

justintime’s picture

Status: Needs review » Fixed

Did some whitespace formatting and committed to 3.x-dev. Thanks for the patch!

Automatically closed -- issue fixed for 2 weeks with no activity.