Browse code

Fix file notification job

Benjamin Roth authored on08/09/2023 16:29:35
Showing1 changed files
... ...
@@ -68,14 +68,19 @@ class SecureDownloadsJob
68 68
                     {
69 69
                         if (($Member = MemberModel::findOneBy(array("disable != '1'","login = '1'","email LIKE '%@%'","id = ?"),array($member['pid']))) !== null)
70 70
                         {
71
-                            $Files = $this->db->executeQuery("SELECT s.id, f.name, s.ctime FROM tl_member_secureDownloads s INNER JOIN tl_files f ON f.uuid = s.uuid WHERE s.pid = ? AND s.nc_sent != '1' ORDER BY s.ctime DESC, f.name",[$Member->id]);
71
+                            $Files = $this->db->executeQuery("SELECT s.id, f.uuid, s.ctime FROM tl_member_secureDownloads s INNER JOIN tl_files f ON f.uuid = s.uuid WHERE s.pid = ? AND s.nc_sent != '1' ORDER BY s.ctime DESC, f.name",[$Member->id]);
72
+                            $arrFileIds = [];
72 73
 
73 74
                             if ($Files->rowCount())
74 75
                             {
75 76
                                 $arrDownloads = array();
76
-                                foreach ($Files as $file)
77
+                                foreach ($Files->iterateAssociative() as $file)
77 78
                                 {
78
-                                    $arrDownloads[] = date('d.m.Y', $file['ctime']) . " - " . $file['name'];
79
+                                    if (($File = FilesModel::findByUuid($file['uuid'])) !== null)
80
+                                    {
81
+                                        $arrDownloads[] = date('d.m.Y', $file['ctime']) . " - " . $File->name;
82
+                                        $arrFileIds[] = $file['id'];
83
+                                    }
79 84
                                 }
80 85
 
81 86
                                 $Notification->send(array
... ...
@@ -89,7 +94,6 @@ class SecureDownloadsJob
89 94
                             }
90 95
 
91 96
                             // Flag news as sent
92
-                            $arrFileIds = $Files->fetchFirstColumn();
93 97
                             $this->db->executeStatement("UPDATE tl_member_secureDownloads SET nc_sent = '1' WHERE id IN (" . implode(',', $arrFileIds) . ")");
94 98
                         }
95 99
                     }