next()) { $Archive = $Archives->current(); $arrGroupIds = deserialize($Archive->nc_notification_groups,true); $time = \Date::floorToMinute(); // Do we have new news items $News = \Database::getInstance()->prepare("SELECT id, alias, headline, date, teaser FROM tl_news WHERE pid = ? AND nc_sent != '1' AND (start='' OR start<='$time') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1' ORDER BY date DESC, time DESC") ->execute($Archive->id); // Load groups and notification models if we have news to share if ($News->numRows && ($Notification = \NotificationCenter\Model\Notification::findByPk($Archive->nc_notification)) !== null && ($Groups = \MemberGroupModel::findMultipleByIds($arrGroupIds)) !== null) { while ($Groups->next()) { // Skip disabled groups if ($Groups->disable) { continue; } // Get group members $Members = \MemberModel::findBy(array("groups LIKE '%\"".$Groups->id."\"%'","login='1' AND (start='' OR start<='$time') AND (stop='' OR stop>'" . ($time + 60) . "') AND disable=''"),null); // Send notification to each member if ($Members !== null) { $arrNews = array(); $arrNewsPlain = array(); $News->reset(); while ($News->next()) { $arrRow = array( 'date' => date('d.m.Y',$News->date), 'headline' => $News->headline, 'teaser' => \Contao\StringUtil::substr(strip_tags(str_ireplace(array('
','
','
','

','

'),' ',$News->teaser)),128) ); if (($objJumpTo = $Archive->getRelated('jumpTo')) !== null) { $objJumpTo->loadDetails(); $arrRow['url'] = ($objJumpTo->rootUseSSL ? 'https://' : 'http://') . $objJumpTo->domain . TL_PATH . '/' . \Controller::generateFrontendUrl($objJumpTo->row(),((\Config::get('useAutoItem') && !\Config::get('disableAlias')) ? '/' : '/items/') . ((!\Config::get('disableAlias') && $News->alias != '') ? $News->alias : $News->id)); } $arrNews[] = $arrRow; $arrNewsPlain[] = date('d.m.Y',$News->date).' - '.$News->headline; $arrNewsHtml[] = '

'.$arrRow['date'].' '.$arrRow['headline'].'

'.$arrRow['teaser'].'

'. ($arrRow['url'] ? '

» Neuigkeit lesen...

' : '') .'
'; } while ($Members->next()) { if (!$Members->nc_news_subscribe) { continue; } $Notification->send(array ( 'member_email' => $Members->email, 'member_firstname' => $Members->firstname, 'member_lastname' => $Members->lastname, 'news_topics' => implode("\n",$arrNewsPlain), 'news_topics_html' => "" ), $GLOBALS['TL_LANGUAGE']); } } // Flag news as sent $arrNewsIds = $News->fetchEach('id'); \Database::getInstance()->execute("UPDATE tl_news SET nc_sent = '1' WHERE id IN (".implode(',',$arrNewsIds).")"); } } } } } }