allow base64 encoded prepopulation values

bobthecow - January 22, 2008 - 00:33
Project:Prepopulate
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:active
Description

i needed a way to prepopulate fields but not be blatantly obvious about it, so i figured i'd share how i did it.

insert the following at line 35 of prepopulate.module:

<?php
 
// get base64encoded prepopulate values
 
if (variable_get('prepopulate_allowed_' . $type, TRUE) && $_GET['pp']) {
     
parse_str(base64_decode($_GET['pp']),$_GET);
  }
?>

this allows you to base64 encode a query string and pass it to the page as ?pp=

for example, if you have the query string:

<?php
  $query
= 'edit[title]=' . urlencode($titlestring) . '&edit[body]=' . urlencode($bodystring)
?>

you can encode it like this:

<?php
  $encoded_query
= 'pp=' . base64_encode($query);
?>

resulting in a hideously long and not so blatantly obvious prepopulating query :)

#1

add1sun - March 16, 2008 - 15:29
Version:5.x-1.x-dev» 6.x-1.x-dev

If this goes in, it will need to be option that is off by default and can be turned on in the settings, with a reasonable explanation of what it is and why you'd use it. This would also go in the D6 version 2 of the module.

#2

bobthecow - April 1, 2008 - 04:37

I think the beauty of this is that it's "off" by default. unless someone creates a url with "pp=XXX" and adds a base64 encoded value, it will do nothing. Adding a configuration option to disable this might be a bit overkill.

Perhaps mentioning it in the documentation as an available option (along with a use case and example) would be enough?

#3

add1sun - April 6, 2008 - 01:40

Ahh gotcha, for some reason I completely blew by the && $_GET['pp'] in there. :p I'll add this to the module in the V2 that's a-coming. I probably won't get time for that for a few weeks.

 
 

Drupal is a registered trademark of Dries Buytaert.