51
deka87
Re: Notifications based on criteria
  • 2009/8/21 5:54

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


trabis isn't this line
$criteria2->new CriteriaCompo('source_language'$ads->getVar('ads_lang2')));
supposed to be like others
$criteria1 = new CriteriaCompo(new Criteria('source_language'$ads->getVar('ads_lang2')));
?

also i want to include all users those from the first compo and from the second compo maybe it should be like this
$criteria = new CriteriaCompo($criteria1); 
if (
$vice_versa == 1) { 
    
$criteria->add($criteria2'AND'); 
}


or im missing the point?

52
trabis
Re: Notifications based on criteria
  • 2009/8/21 11:00

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Hi Deka, yes, my mistake in that line.

you want something like
man are black and woman are white
or
man are white and woman are black

(this will cover half of the world)

if you ask for
man are black and man are white and woman are black and woman are white
result will be 0 users because no man is black and white at same time.

(I know what you're thinking, you're bad)


53
deka87
Re: Notifications based on criteria
  • 2009/8/21 11:34

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


yea i think i got it now trabis, your right. i dont know if you remember that the whole thingy is to make a list of users ($user_list = array_keys($users); ) who meet the criteria and send them notifications. the problem is that if the number of users who meet the criteria is zero it sends the notifications to all the users neglecting the criteria. how do I abort the whole sending procedure if the number of users is 0?

54
ghia
Re: Notifications based on criteria
  • 2009/8/21 11:50

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


See if there is anything found with:
if (is_array($users)&& (count($users) > 0))


55
trabis
Re: Notifications based on criteria
  • 2009/8/21 11:58

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Like ghia says, you can enclosure the notification inside and if condition:
if (is_array($users)&& (count($users) > 0)) {
//notification triggerEvent goes here
}


If that is to much trouble than you can create a fake user list, in this case the notification will be trigger but since no user is found, it will abort. This will not save you processing but will work:
if (!is_array($users)|| (count($users) == 0)) {
   
$users = array('999999999'); //this a userid that will not be found.
}



56
deka87
Re: Notifications based on criteria
  • 2009/8/21 13:42

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


oh great guys. thanks for your help

57
deka87
Re: Notifications based on criteria
  • 2009/8/26 12:46

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


there is something wrong with the code

//notifications hack 

$user_handler =& xoops_getmodulehandler('profile''profile'); 

$criteria1 = new CriteriaCompo(new Criteria('source_language'$ads->getVar('ads_lang1'))); 
$criteria1->add(new Criteria('target_language'$ads->getVar('ads_lang2'))); 

$criteria1 = new CriteriaCompo(new Criteria('source_language'$ads->getVar('ads_lang2')));
$criteria2->add(new Criteria('target_language'$ads->getVar('ads_lang1'))); 

$criteria = new CriteriaCompo($criteria1); 
if (
$vice_versa == 1) { 
    
$criteria->add($criteria2'OR'); 


$users $user_handler->getList($criteria); 
unset(
$criteria$criteria1$criteria2); 

$user_list array_keys($users);

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

//end of hack


i believe i have problems retrieving $vice_versa. am i right?

58
trabis
Re: Notifications based on criteria
  • 2009/8/26 13:55

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

deka87 wrote:
there is something wrong with the code

i believe i have problems retrieving $vice_versa. am i right?


Maybe.

There is a bug there:
In the second row of criterias it should be $criteria2 = new ....

Login

Who's Online

368 user(s) are online (263 user(s) are browsing Support Forums)


Members: 0


Guests: 368


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