Hi! I made a little hack to

crooke's picture
Offline
Joined: 03/15/2008
Juice: 77
Hi! I made a little hack to

Hi!

I made a little hack to give the user the ability to make the wish list private with a drop down box. I don't really know how to do patches, but hopefully it will be helpful to someone.

You need to create a new column in the {uc_wishlists} table, called private. (This is probably not the best solution, it should be included in the .install file)

The changes in uc_wishlist.module:

line 96
$res = db_query("SELECT DISTINCT w.wid, w.title FROM {uc_wishlists} AS w JOIN {users} AS u ON w.uid = u.uid WHERE u.name LIKE '%%%s%%' OR w.title LIKE '%%%s%%' OR w.address LIKE '%%firstname%%%s%%addr1%%' ORDER BY w.title", $query, $query, $query);

change to:
$res = db_query("SELECT DISTINCT w.wid, w.title FROM {uc_wishlists} AS w JOIN {users} AS u ON w.uid = u.uid WHERE w.private = '0' AND u.name LIKE '%%%s%%' OR w.title LIKE '%%%s%%' OR w.address LIKE '%%firstname%%%s%%addr1%%'  ORDER BY w.title", $query, $query, $query);

add this after line 1059:

$form ['ws']['private'] = array(
  '#type' => 'select',
'#title' => t('Make private'),
'#description' => t('Use this box to make your list private'),
'#options' => array( '0'=> 'No', '1' => 'Yes'),
  );

add this after line 1081:
$private = $form_values['private'];

change line 1097
uc_wishlist_update_wishlist($wid, $title, $date, $address);

to:

uc_wishlist_update_wishlist($wid, $title, $date, $address, $private);

change line 1269

$res = db_query("INSERT INTO {uc_wishlists} (wid, uid, title, date) VALUES (%d, '%s', '%s', %d)", $wid, $uid, $title, $date);

to:

$res = db_query("INSERT INTO {uc_wishlists} (wid, uid, title, date, private) VALUES (%d, '%s', '%s', %d, '%s')", $wid, $uid, $title, $date, $private);

change line 1276

function uc_wishlist_update_wishlist($wid, $title, $date, $address) {
//TODO combine with uc_wishlist_create_wishlist?
  $addrstr = serialize($address);
  db_query("UPDATE {uc_wishlists} SET title = '%s', date = %d, address = '%s' WHERE wid = %d", $title, $date, $addrstr, $wid);
}

to:

function uc_wishlist_update_wishlist($wid, $title, $date, $address, $private) {
//TODO combine with uc_wishlist_create_wishlist?
  $addrstr = serialize($address);
  db_query("UPDATE {uc_wishlists} SET title = '%s', date = %d, address = '%s', private = '%s' WHERE wid = %d", $title, $date, $addrstr, $private, $wid);
}

This got me up and running, please review it and let me know if it's a good and working solution.

Rob

Wish list/gift registry module By: detour (42 replies) Thu, 10/18/2007 - 02:30