11
deka87
Re: Notifications based on criteria
  • 2008/12/19 4:27

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


I am a bit confused.

So what I've got to do is to add ghia's code first

$sql '
SELECT * FROM '
.$this->db->prefix('xoopsnotifications').
LEFT JOIN '
.$this->db->prefix('user_profile').
 ON not_uid = profileid 
WHERE
 not_modid = '
.$mod_id.' AND
 not_itemid = '
.0.' AND
 not_category = '
."'global'".' AND
 not_event = '
."'ads_submit'".' AND
 ((source_language <> '
.$ads->getVar('ads_lang1').') OR
  (target_language <> '
.$ads->getVar('ads_lang2').'))';


then the one provided by trabis

$user_list = array('1','23','134');//do this your way
$notification_handler->triggerEvent('global'0'ads_submit'$tags$user_list);


but im not sure what i've got to write in

array('1','23','134')
Mind anchors

12
ghia
Re: Notifications based on criteria
  • 2008/12/19 11:32

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


My part is only the SQL query string. It has to be executed at the database (add some code with eg $xoopsDB->query($sql) for it) and then the returned result set has the data for filling your $user_list.

13
deka87
Re: Notifications based on criteria
  • 2008/12/19 14:53

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


i really suck in php, so sorry for my silly questions a priori.

so is this supposed to be like this:

$xoopsDB->query($sql)

$sql '
SELECT * FROM '
.$this->db->prefix('xoopsnotifications').
LEFT JOIN '
.$this->db->prefix('user_profile').
 ON not_uid = profileid 
WHERE
 not_modid = '
.$mod_id.' AND
 not_itemid = '
.0.' AND
 not_category = '
."'global'".' AND
 not_event = '
."'ads_submit'".' AND
 ((source_language <> '
.$ads->getVar('ads_lang1').') OR
  (target_language <> '
.$ads->getVar('ads_lang2').'))';

$user_list = array('1','23','134');//do this your way
$notification_handler->triggerEvent('global'0'ads_submit'$tags$user_list);


or i'm missing soemthing again..
Mind anchors

14
trabis
Re: Notifications based on criteria
  • 2008/12/19 20:35

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

I have also added two custom lines in the registration form: "$source_language" and "$target_language".


How have you done this? Did you use profile module or hacked kernel/user.php?

How did you populate those variables in the peace of code you submitted?

15
deka87
Re: Notifications based on criteria
  • 2008/12/19 22:07

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


those variables were added in the profile module. the piece of code i submitted the first time is taken from catads/submit1.php so it doesn't contain those variable.
Mind anchors

16
trabis
Re: Notifications based on criteria
  • 2008/12/19 22:20

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Using Ghia sql it would be like this:
$sql '
SELECT * FROM '
.$this->db->prefix('xoopsnotifications').
LEFT JOIN '
.$this->db->prefix('user_profile').
 ON not_uid = profileid 
WHERE
 not_modid = '
.$mod_id.' AND
 not_itemid = '
.0.' AND
 not_category = '
."'global'".' AND
 not_event = '
."'ads_submit'".' AND
 ((source_language <> '
.$ads->getVar('ads_lang1').') OR
  (target_language <> '
.$ads->getVar('ads_lang2').'))';

$result $xoopsDB->query($sql);
$user_list = array();
while(
$row $xoopsDB->fetchArray($result)){
   
$user_list[] = $row['not_uid'];
}

$notification_handler->triggerEvent('global'0'ads_submit'$tags$user_list);


I don´t know what you want to match exactly.
I need to know the country field name you use on profile and the variable that contains the country in the ads code.

17
deka87
Re: Notifications based on criteria
  • 2008/12/20 8:07

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


I gave the code a try and replaced the original

$notification_handler->triggerEvent('global'0'ads_submit'$tags);


with the code you provided:

$sql '
SELECT * FROM '
.$this->db->prefix('xoopsnotifications').
LEFT JOIN '
.$this->db->prefix('user_profile').
 ON not_uid = profileid 
WHERE
 not_modid = '
.$mod_id.' AND
 not_itemid = '
.0.' AND
 not_category = '
."'global'".' AND
 not_event = '
."'ads_submit'".' AND
 ((source_language <> '
.$ads->getVar('ads_lang1').') OR
  (target_language <> '
.$ads->getVar('ads_lang2').'))';

$result $xoopsDB->query($sql);
$user_list = array();
while(
$row $xoopsDB->fetchArray($result)){
   
$user_list[] = $row['not_uid'];
}

$notification_handler->triggerEvent('global'0'ads_submit'$tags$user_list);



but unfortunately this caused a blank page.

I am trying to match $source_language from the registration form with $ads_lang1 from the catads module AND $target_language from the registration form and $ads_lang2 from the catads module. So a user has got to be notified (if he subscribed to notifications ofc) when a new ad is posted matching his criteria i.e. when ad's $ads_lang1 = his $source_language AND ad's $ads_lang2 = his $target_language. I gave up the idea with the coutry so what I have mentioned above is what I focus on.

You may want to take a look here:

Here is a registration form: http://freelancersupport.com/modules/profile/register.php which contains $source_language and $target_language (under Source language and Target language titles)

and the ad posting form: http://freelancersupport.com/modules/catads/submit1.php?cat_id=1

which contains $ads_lang1 (which is Source language in the ads submission form) and $ads_lang2 (which is Target language in the ads submission form).
Mind anchors

18
ghia
Re: Notifications based on criteria
  • 2008/12/20 11:29

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


The intention of the script is to inform only users with the right countries in their source and target profile fields.

See that debug is on.

We gonna have to test this in steps.
1 Revert the code.
2 Make a new category, for not bothering other users.
3 Make a new ordinary user with an email address that you can monitor.
4 Make a new ad and see if notification is received.
5 Add/modify to
$user_list = array('123');
$notification_handler->triggerEvent('global'0'ads_submit'$tags$user_list);

Replace 123 to the userid from step 3
6 Make a new ad and see no notification is received
7 Modify to
$sql 'SELECT * FROM '.$this->db->prefix('xoopsnotifications').' WHERE not_uid = 123 LIMIT 1'  
$result $xoopsDB->query($sql);
$user_list = array();
while(
$row $xoopsDB->fetchArray($result)){
   
$user_list[] = $row['not_uid'];
}

$notification_handler->triggerEvent('global'0'ads_submit'$tags$user_list);
Replace 123 to the userid from step 3
8 Make a new ad and see no notification is received

19
deka87
Re: Notifications based on criteria
  • 2008/12/20 12:19

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


OK, my report starting from the 4th step:

4. Notification is received
5. Done
6. Notification is still received.
7. Done
8. Unable to reach catads/submit1.php only get a blank page.

As in regard to the 6th step, just a suggestion: all the ads before publishing have to be approved by the administrator, so I click the "publish" link on http://freelancersupport.com/modules/catads/admin/index.php. The publish link url is http://freelancersupport.com/modules/catads/admin/adsmod.php?op=approve&ads_id=13. Maybe we need to edit some other script?

Mind anchors

20
trabis
Re: Notifications based on criteria
  • 2008/12/20 12:52

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


If they have to be approved then we are looking at the wrong event. We are doing this on ads submit where it should be on ads approve. You must find the file were you approve the ads and look for notification->triggerevent. Should be in admin folder.

Login

Who's Online

361 user(s) are online (262 user(s) are browsing Support Forums)


Members: 0


Guests: 361


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits