antoniop
committed
on 14 Dec 20
file upgrade-0.5d1-0.5d2.sql was initially added on branch oacs-5-10.
/tcl/notification-procs.tcl (+3 -5)
240 240                 # Restructure already_notified as an array for quick lookups
241 241                 foreach entry $already_notified {
242 242                     set already_notified_p($entry) 1
243 243                 }
244 244
245 245                 if { $subset_arg_p } {
246 246
247 247                     # Restructure subset as an array for quick lookups
248 248                     foreach user_id $subset {
249 249                         set subset_member_p($user_id) 1
250 250                     }
251 251
252 252                     # Delete request that shouldn't be there
253 253                     foreach entry [array names request] {
254 254                         # if not in subset, delete
255 255                         # if in already_notified, delete
256 256
257 257                         set user_id [lindex $entry 0]
258 258
259 259                         if { ![info exists subset_member_p($user_id)] || [info exists already_notified_p($entry)] } {
260                               array unset request $entry
  260                             unset request($entry)
261 261                         }
262 262                     }
263 263
264 264                     if { $force_p } {
265 265                         # Add requests that should be forced
266 266                         foreach user_id $subset {
267 267                             if { [llength [array get request "$user_id,*"]] == 0 } {
268 268                                 set entry "$user_id $default_request(interval_id) $default_request(delivery_method_id)"
269 269                                 set request($entry) $default_request(format)
270 270                             }
271 271                         }
272 272                     }
273 273                 } else {
274 274                     # Get rid of users who are on the already notified list
275 275                     foreach entry $already_notified {
276 276                         # If user has already received a notification with the same
277 277                         # interval and delivery method, don't send again
278                           if { [info exists request($entry)] } {
279                               array unset request $entry
  278                         unset -nocomplain request($entry)
280 279                     }
281 280                 }
282                   }
283 281
284 282                 if { $return_notified_p } {
285 283                     set notified_list [array names request]
286 284                 }
287 285             } else {
288 286                 # Normal notification
289 287                 if { $return_notified_p } {
290 288                     set notified_list [db_list_of_lists select_notified {}]
291 289                 }
292 290             }
293 291
294 292             if { $notif_user eq "" && [ns_conn isconnected] } {
295 293                 set notif_user [ad_conn user_id]
296 294             }
297 295
298 296             # Actually carry out inserting the notification
299 297             db_transaction {
300 298                 if { $subset_arg_p || $already_notified_arg_p } {
301 299                     foreach entry [array names request] {
302 300