41
deka87
Re: Notifications based on criteria
  • 2008/12/22 13:20

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


i don't think so. it's just that i'd make the source and target language variables in the profile module like this: $source_language[i]. I'm not good in php but I thought it may be done this way. i'd also try to edit catads module scripts to make ads_lang1 and ads_lang2 dropdown too like ads_lang1[i].

isn't it gonna be something like this?

$user_handler =& xoops_gethandler('user');
$criteria = new CriteriaCompo(new Criteria('source_language[i]'$ads->getVar('ads_lang1[i]')));
$criteria->add(new Criteria('target_language[i]'$ads->getVar('ads_lang2[i]')));
$users $user_handler->getList($criteria);
unset(
$criteria);
$user_list array_keys($users);


or i have to do something with array.
Mind anchors

42
trabis
Re: Notifications based on criteria
  • 2008/12/22 21:24

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Ghia is correct. You do not have to change anything on the code. Just go to profile and change 'text field' to 'select' and enter your options.

43
deka87
Re: Notifications based on criteria
  • 2009/1/18 14:02

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


I have discovered a bug. It sends notification to all members inspite of their languages when someone submits a job with language combination no users have. Like I have no Japanese - Chuvash users, so if someone submits a Japanese - Chuvash job everybody will get a notification about this job. weird huh
Mind anchors

44
deka87
Re: Notifications based on criteria
  • 2009/7/28 9:04

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


I have upgraded to 2.3.3 and this code doesn't work anymore. What do I need to change to get this code working on 2.3.3?

$user_handler =& xoops_gethandler('user');
$criteria = new CriteriaCompo(new Criteria('source_language'$ads->getVar('ads_lang1')));
$criteria->add(new Criteria('target_language'$ads->getVar('ads_lang2')));
$users $user_handler->getList($criteria);
unset(
$criteria);
$user_list array_keys($users);
Mind anchors

45
trabis
Re: Notifications based on criteria
  • 2009/7/28 12:30

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Try replace
$user_handler =& xoops_gethandler('user');

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

46
deka87
Re: Notifications based on criteria
  • 2009/7/29 9:21

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


thanks trabis! i'll see if it works when a new job is posted.
Mind anchors

47
deka87
Re: Notifications based on criteria
  • 2009/8/20 14:26

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


$user_handler =& xoops_getmodulehandler('profile''profile'); 
$criteria = new CriteriaCompo(new Criteria('source_language'$ads->getVar('ads_lang1')));
$criteria->add(new Criteria('target_language'$ads->getVar('ads_lang2')));
$users $user_handler->getList($criteria);
unset(
$criteria);
$user_list array_keys($users);


it works trabis. I have one more question. I have a field $vice_versa. How I do I also add users to $user_list for whom $vice_versa == 1 and $source_language == $ads_lang2 AND $target_language == $ads_lang1?

is it something like this?

$user_handler =& xoops_getmodulehandler('profile''profile'); 
$criteria = new CriteriaCompo(new Criteria('source_language'$ads->getVar('ads_lang1')));
$criteria->add(new Criteria('target_language'$ads->getVar('ads_lang2')));
if 
$vice_versa {
$criteria->add(new Criteria('source_language'$ads->getVar('ads_lang2')));
$criteria->add(new Criteria('target_language'$ads->getVar('ads_lang1')));
}
$users $user_handler->getList($criteria);
unset(
$criteria);
$user_list array_keys($users);



48
trabis
Re: Notifications based on criteria
  • 2009/8/20 14:39

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


It is not far, no.

I don't know where does the $vice_versa comes from but try this:
$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')));

$criteria2->new CriteriaCompo('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);
?>

49
deka87
Re: Notifications based on criteria
  • 2009/8/20 15:13

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


$vice_versa is also a user profile field.

so i think i got the point. i need to create a compo for every case and then create a compo for the two compoes above. i plan to add ads_lang3 and ads_lang4 later. i hope I will manage to edit this code myself then. thanks!

50
trabis
Re: Notifications based on criteria
  • 2009/8/20 15:38

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


((criteria1 AND criteria2) OR (criteria3 AND criteria4))

Consider each group of() has a CriteriaCompo. You need 3 compos here.

What you were trying to do was more like:
(criteria1 AND criteria2 AND criteria3 AND criteria4)

Or like this if you were adding an 'or':
(criteria1 AND criteria2 OR criteira3 AND criteria4)

This would not have worked as expected.






Login

Who's Online

484 user(s) are online (94 user(s) are browsing Support Forums)


Members: 0


Guests: 484


more...

Donat-O-Meter

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

Latest GitHub Commits