/** * * @param $params */ protected function sendNotificationEmail(array $linkIds, $deleted = false) { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->addAll(Pap_Db_Table_DirectLinkUrls::getInstance()); $selectBuilder->from->add(Pap_Db_Table_DirectLinkUrls::getName()); $selectBuilder->where->add(Pap_Db_Table_DirectLinkUrls::ID, 'IN', $linkIds); $usersMailTemplates = $this->getLinks($selectBuilder->getAllRowsIterator(), $deleted); foreach ($usersMailTemplates as $userId => $mail) { try { $user = $this->loadUser($userId); } catch (Gpf_DbEngine_NoRowException $e) { Gpf_Log::warning($this->_('Error load affiliate with userid=' . $userId . ', mail will not be send.')); continue; } $attribute = $this->loadAttributes($user->getAccountUserId()); if (Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_ENABLED) == Gpf::YES) { $isNotify = $attribute->getAttributeWithDefaultValue(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_ENABLED, Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_DEFAULT)); } else { $isNotify = Gpf_Settings::get(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_DEFAULT); } if ($isNotify == Gpf::YES) { $mail->setUser($user); $mail->addRecipient($user->getEmail()); try { $mail->send(); } catch (Exception $e) { Gpf_Log::error($this->_('Error sending direct link changed status notification email to affiliate: %s', $e->getMessage())); } } } }
function init() { $this->setTable(Pap_Db_Table_DirectLinkUrls::getInstance()); parent::init(); }