Browse code

Updates

Benjamin Roth authored on22/03/2023 10:08:48
Showing2 changed files
... ...
@@ -30,9 +30,8 @@ $GLOBALS['TL_DCA']['tl_news']['fields']['nc_sent'] = array
30 30
 (
31 31
   'exclude'                 => true,
32 32
   'inputType'               => 'checkbox',
33
-  'default'                 => 1,
34 33
   'eval'                    => array('doNotCopy'=>true),
35
-  'sql'                     => "char(1) NOT NULL default ''"
34
+  'sql'                     => "char(1) NOT NULL default '1'"
36 35
 );
37 36
 
38 37
 $GLOBALS['TL_DCA']['tl_news']['fields']['nc_testmail'] = array
... ...
@@ -80,6 +80,7 @@ class SendNewsNotificationJob
80 80
                         {
81 81
                             $arrNews = array();
82 82
                             $arrNewsPlain = array();
83
+                            $arrNewsIds = array();
83 84
                             foreach ($News->iterateAssociative() as $item)
84 85
                             {
85 86
                                 $arrRow = array(
... ...
@@ -90,13 +91,15 @@ class SendNewsNotificationJob
90 91
 
91 92
                                 if (($objJumpTo = $Archive->getRelated('jumpTo')) !== null)
92 93
                                 {
93
-                                    $arrRow['url'] = $objJumpTo->getAbsoluteUrl(sprintf((Config::get('useAutoItem') ? '/%s' : '/items/%s'),$News->alias)).'?ltoken=%%_TOKEN_%%';
94
+                                    $arrRow['url'] = $objJumpTo->getAbsoluteUrl(sprintf((Config::get('useAutoItem') ? '/%s' : '/items/%s'),$item['alias'])).'?ltoken=%%_TOKEN_%%';
94 95
                                 }
95 96
 
96 97
                                 $arrNews[] = $arrRow;
97 98
 
98 99
                                 $arrNewsPlain[] = date('d.m.Y',$item['date']).' - '.$item['headline'];
99 100
                                 $arrNewsHtml[] = '<div style="margin-bottom: 15px;"><h3>'.$arrRow['date'].' '.$arrRow['headline'].'</h3><p>'.$arrRow['teaser'].'</p>'. ($arrRow['url'] ? '<p><a href="'.$arrRow['url'].'">&raquo; Ganze Nachricht lesen...</a></p>' : '') .'</div>';
101
+
102
+                                $arrNewsIds[] = $item['id'];
100 103
                             }
101 104
                             while ($Members->next())
102 105
                             {
... ...
@@ -123,12 +126,11 @@ class SendNewsNotificationJob
123 126
                     }
124 127
 
125 128
                     // Flag news as sent
126
-                    $arrNewsIds = array();
127
-                    foreach ($News->iterateAssociative() as $newsRow)
129
+                    if (count($arrNewsIds))
128 130
                     {
129
-                        $arrNewsIds[] = $newsRow['id'];
131
+                        $strNewsIds = implode(',',$arrNewsIds);
132
+                        $this->db->executeStatement("UPDATE tl_news SET nc_sent = '1' WHERE id IN ($strNewsIds)");
130 133
                     }
131
-                    $this->db->executeStatement("UPDATE tl_news SET nc_sent = '1' WHERE id IN (".implode(',',$arrNewsIds).")");
132 134
                 }
133 135
             }
134 136
         }