return the uploaded image’s entry id
Posted: 23 September 2007 05:02 PM   [ Ignore ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  118
Joined  2005-09-13

The following will only work if you’re uploading one image at a time, but the idea here is that on return of the exp:gallery_extended:form tag that you can have the entry_id of that photo in order to ensure that on the returned page where you might have an SAEF it’s definitely the user’s uploaded image and not just the most recent one.

Swap out everything starting on line 1050 of mod.gallery_extended.php and ending where the comment says //end insert

// -------------------------------------------
  //  Get out
  // -------------------------------------------
  
  if ($IN->GBL('override_resize', 'POST') == 'yes' );
  
  if (
stristr( $return, "http" ) )
  
{
   $FNS
->redirect( $return );
  
}
  
elseif ( stristr ( $return, "&#xen;try%" ) ) // This is where wondermonkey takes over to try to send back an entry_id
  
{
   $query
= $DB->query( "SELECT entry_id FROM exp_gallery_entries WHERE entry_date = '".$fields['entry_date']."' AND author_id = '".$SESS->userdata('member_id')."'" ); //try to find the entry that the module just created.
  
   
   
if (! $query->num_rows == 0 )
   
{
$return
= str_replace('&#xen;try%',$query->row['entry_id'],$return); //Now grab and swap the &#xen;try% from the return URL with the entry_id we just garnered. Boom. Better than an extension.
   
}
   
   $FNS
->redirect( $FNS->create_url( $return ) );
  
}
  
else
  
{
   $FNS
->redirect( $FNS->create_url( $return ) );
  
}
   
  
exit;  
}

// End insert

In order to use this, you’ll need to add n;try% after your templategroup/template to the return parameter of your gallery_extended:form tag, such as:

{exp:gallery_extended:entry_form gallery_name="my_g_name" redirect="{path=upload/entry}" form_id="uploadForm" type="weblog" return="/upload/entry/&#xen;try%" onsubmit = "[removed] void(0);" override_resize = "yes"}

Hope this makes it into the next version Mitchell!

Profile
 
 
Posted: 23 September 2007 05:12 PM   [ Ignore ]   [ # 1 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  118
Joined  2005-09-13

Um, the forum keeps taking my percent symbols and making them into garbled goop.

All the n;try% should be percententrypercent or % entry % but without the spaces…

Profile
 
 
Posted: 24 September 2007 01:40 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  693
Joined  2004-03-30

Let me try. Here’s a percent symbol %.

 Signature 

Mitchell Kimbrough

Profile
 
 
Posted: 24 September 2007 01:41 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  693
Joined  2004-03-30

Here’s one around an entry n;try%

 Signature 

Mitchell Kimbrough

Profile
 
 
Posted: 24 September 2007 01:43 PM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  693
Joined  2004-03-30

I’m pretty sure that what you’re seeing Tyler is the Forum module invoking $REGX->xss_clean on the POST array. It’s trying to prevent us from doing something nefarious.
smile

mk

 Signature 

Mitchell Kimbrough

Profile