Skip to content

Commit

Permalink
AI-55 Fixed duplicate sending of terms
Browse files Browse the repository at this point in the history
  • Loading branch information
Edzelopez committed Mar 30, 2016
1 parent f7c0b4c commit 1eaff5b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CRM/Attentively/BAO/Attentively.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,17 @@ static public function pushWatchedTerms() {
if (empty($terms)) {
return array('error' => ts('You have not specified any watched terms. Please specify them at Administer >> System Settings >> Option Groups >> Attentive.ly Watched Terms'));
}
$terms = '&terms=' . implode(',' , $terms);
// First get all watched terms.
self::pullWatchedTerms();
$dao = CRM_Core_DAO::executeQuery("SELECT term, nickname FROM civicrm_attentively_watched_terms");
while ($dao->fetch()) {
$savedTerms[$dao->nickname] = $dao->term;
}
$terms = array_diff($terms, $savedTerms); // Send only those terms which are not present on Attentive.ly
if (empty($terms)) {
return array('error' => ts('All of the terms specified exist in Attentive.ly.'));
}
$terms = '&terms=' . implode(',', $terms);
$result = self::getAttentivelyResponse('watched_terms_add', $terms);
if ($result['success']) {
return count($result['parameters']->terms);
Expand Down

0 comments on commit 1eaff5b

Please sign in to comment.