Results 1 to 4 of 4
  1. #1
    Registered User/Coder
    Join Date
    May 2011
    Location
    Melbourne Australia
    Posts
    15

    Default Auction watch - how to enter a phrase?

    Hi all,
    Just wondering if anyone has any ideas about how the auction watch function could be modded to include a phrase? At the moment, it explodes any phrase into individual words. So, if I enter 'yellow couch', it emails when anything 'yellow' is added (like a car) and anything like 'couch' (even the red ones), but I really just want to know when someone adds a 'yellow couch'!!!! You get the idea I'm sure. It's a great function and my users are going to be mad for it, but it's a bit limited in its present form.

    I've tried a couple of things but only seem to be able to break the function, so I thought someone here might have an idea?

  2. #2
    Super Moderator/Coder/Designer nay27uk's Avatar
    Join Date
    Nov 2009
    Location
    Leicester, UK
    Posts
    3,617

    Default

    HMMMMMM sounds like an interesting one to look into

  3. #3
    Registered User/Coder
    Join Date
    May 2011
    Location
    Melbourne Australia
    Posts
    15

    Default

    So, I've been taking a look. The current functionality seems a bit limited, but can proabably be modded without too much effort. At the moment, users enter a word via the alert page of their control panel. The words they enter get stored in the db, space separated. In sell.php, when a user adds an auction, the list of alert words gets exploded, as does the item title and description, the two arrays are compared and if there's a match, it sends of an email to the user. So the function as it stands can only look for individual words.

    Adding the keywords as comma separated is not difficult, but it's a PAIN to try to get the delete function to work, and keep the commas in the right place, because the list of keywords is actually entirely rebuilt and returned to the db after each delete. If anyone can suggest how this could be done I'd appreciate it!

    I think the best way forward to aceive the mod may be to create a new table in the database, storing all the keywords for each user, and use the search function to look for word and phrase matches, then trigger the emails. That said, I'm still going to mess about with the comma separated list to see if that could achieve what I've suggested above. I'll pass on the results for those who are interested.
    Last edited by Andrew Hacker; 22-04-2012 at 04:54 AM.

  4. #4
    Registered User/Coder
    Join Date
    May 2011
    Location
    Melbourne Australia
    Posts
    15

    Default More details

    OK, getting somewhere now.

    I've attached a new version of auction_watch.php, which will now store and present the items as comma separated values. It works, but it's buggy - the array will reverse on each delete - it's minor, but gee it's annoying. Any suggestions are welcome as to how to overcome this.

    Before you do anything, BACKUP both auction_watch.php and sell.php!!

    Replace your auction_watch.php with this one auction_watch.php

    Next, we need to search each new auction for matches on the phrases....

    In sell.php find
    Code:
    // Send notification if users keyword matches (Auction Watch)
    Remove all the code between that line and this (but leave this line alone)

    Code:
    if ($user->user_data['startemailmode'] == 'yes')
    and replace what you delete with

    Code:
    // Send notification if users keyword matches (Auction Watch)
    				$query = "SELECT auc_watch, email, nick, name, id FROM " . $DBPrefix . "users WHERE auc_watch != '' AND id != " . $user->user_data['id'];
    				$result = mysql_query($query);
    				$system->check_mysql($result, $query, __LINE__, __FILE__);
    				$sent_to = array();
    				while ($row = mysql_fetch_assoc($result))
    				{
    					if (isset($match)) unset($match);
    										$w_title = strip_tags($_SESSION['SELL_title']);
    					$w_descr = strip_tags($_SESSION['SELL_description']);
    					$w_nick = $user->user_data['nick'];
    					$key = explode(',', $row['auc_watch']);
    										
    					if (is_array($key) && count($key) > 0)
    					{
    						foreach ($key as $k => $v)
    						{
    							$v = trim(strtolower($v)); 							
    							
    							$match1 = stripos($w_title, $v); 
    							$match2 = stripos($w_descr, $v);
    							if (($match1 !== false || $match2 !== false) && !in_array($row['id'], $sent_to))
    								{
    								$emailer = new email_class();
    								$emailer->assign_vars(array(
    										'URL' => $system->SETTINGS['siteurl'] . 'item.php?id=' . $_SESSION['SELL_auction_id'],
    										'SITENAME' =>  $system->SETTINGS['sitename'],
    										'TITLE' => $_SESSION['SELL_title'],
    										'REALNAME' => $row['name'],
    										'KWORD' => $row['auc_watch']
    										));
    								$emailer->email_uid = $row['id'];
    								$emailer->email_sender($row['email'], 'auction_watchmail.inc.php', $system->SETTINGS['sitename'] . '  ' . $MSG['471']);
    								$sent_to[] = $row['id'];
    								}
    						}
    					}
    				}
    Let everyone now how this works for you.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •