Advertisement:

Author Topic: SOLVED Insert the search url of an alert in db alerts table s_search column?  (Read 555 times)

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Is there a way to insert the search url of an alert in db alerts table s_search column?

Like
"sUrl":"https://.....",



PS. Related https://forums.osclass.org/3-5-x/name-alerts-in-user-alerts-php/msg159275/#msg159275
« Last Edit: January 07, 2018, 04:48:17 pm by marius-ciclistu »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Insert the search url of an alert in db alerts table s_search column?
« Reply #1 on: January 05, 2018, 05:31:01 pm »
Hi,

json_decode(osc_alert_search(), true) returns an array to build the SQL query for alerts, you'd need to do a lot of work to convert that to a normal URL.

For instance, if the original URL contained "category,for-sale" the category element inside that array would have the ID of that parent category plus the ID's of all its subcategories.

Also, custom fields and plugins fields are referenced as SQL query elements.

Anyway, take a look at the array, you'll understand what I am talking about.

Regards

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Insert the search url of an alert in db alerts table s_search column?
« Reply #2 on: January 05, 2018, 06:12:01 pm »
Hi. I knew this before asking  :)

I managed to construct an url without the filters fom no_cache...

Regarding the category, only the first element is needed for url.

When I'll be bored, I'l find a way to squize the url in there.
« Last Edit: January 05, 2018, 06:17:58 pm by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Insert the search url of an alert in db alerts table s_search column?
« Reply #3 on: January 07, 2018, 04:48:04 pm »
I was bored an solved it with mods in: ajax.php, alert-form.php and user-alerts.php.

Now s_search from alerts table contains"sUrl":"https........"}

s_search string can be altered in ajax.php because it's stored in :

$alert          = osc_decrypt_alert(base64_decode($encoded_alert));
« Last Edit: January 07, 2018, 04:55:56 pm by marius-ciclistu »

al

  • Newbie
  • *
  • Posts: 17
i've done a couple of days this :

Code: [Select]
$alert = json_decode(osc_alert_search(), true);

$text = $alert['sPattern'];
$cat_id = $alert['aCategories'][0];
// Ex:  $alert['regions'][0] equals "oc_t_item_location.fk_i_region_id = 1 "
$region_meta = explode(" = ", trim($alert['regions'][0], " "));
$region_id = $region_meta[1];
$city_meta = explode(" = ", trim($alert['cities'][0], " "));
$city_id = $city_meta[1];
$price_min = $alert['price_min'];
$price_max = $alert['price_max'];
if (isset($cat_id)) {
$cat = Category::newInstance()->findByPrimaryKey($cat_id);
}
if (isset($region_id)) {
$region = Region::newInstance()->findByPrimaryKey($region_id);
}
if (isset($city_id)) {
$city = City::newInstance()->findByPrimaryKey($city_id);
}

$url_search = REL_WEB_URL.'index.php?page=search&sOrder=dt_pub_date&iOrderType=desc&sPattern='.$text.'&sCategory='.$cat_id.'&sRegion='.$region_id.'&sCity='.$city_id.'&sPriceMin='.$price_min.'&sPriceMax='.$price_max;

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
This is without custom fields. They are stored in no_cached..something in that array.
The best way is to put there the url.