Beispiel #1
0
 public static function AddReplyNotifications($post_id)
 {
     global $currentUser;
     $post = new ForumPost($post_id);
     // Lista di utenti che hanno risposto al topic, ma che non
     // sono all'interno della skip list
     $q = exequery("SELECT p.user_id as user_id, s.user_id as skip_user_id FROM forum_posts p \n\t\t\t\t\t\t\tLEFT OUTER JOIN forum_notifications_skip_list s ON (s.user_id = p.user_id AND s.topic_id = {$post['root_topic']}) \n\t\t\t\t\t\t\tWHERE p.root_topic = {$post['root_topic']} OR p.id = {$post['root_topic']} GROUP BY user_id\n\t\t\t\t\t\t\tUNION SELECT a.user_id AS user_id, NULL AS skip_user_id\n\t\t\t\t\t\t\tFROM forum_notifications_add_list a WHERE a.topic_id = {$post['root_topic']}\n\t\t\t");
     // Una notifica a ciascuno, non fa male a nessuno
     while ($values = mysqli_fetch_array($q)) {
         if ($values['user_id'] == $currentUser['id']) {
             continue;
         }
         //Skip noi stessi
         if ($values['skip_user_id'] != null) {
             continue;
         }
         //Skippa se richiesto
         exequery("INSERT INTO forum_notifications (topic_id, user_id, notify_tm, post_id, page_num) \n\t\t\t   \tVALUES ('{$post['root_topic']}','{$values['user_id']}'," . time() . ", {$post_id}, " . $post->getPageNumber() . ")");
     }
     //Rimuovi dalla lista di skip_notifications l'user che ha postato
     exequery("DELETE FROM forum_notifications_skip_list \n\t\t\t \t\t\tWHERE user_id = {$currentUser['id']} AND topic_id = {$post['root_topic']}");
 }