mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 12:14:12 +00:00 
			
		
		
		
	Created notification helper
This commit is contained in:
		@@ -56,11 +56,7 @@ class commentsController {
 | 
				
			|||||||
		components()->notifications->push($notification);
 | 
							components()->notifications->push($notification);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Delete any other notification targeting this user about this post
 | 
							//Delete any other notification targeting this user about this post
 | 
				
			||||||
		$notification = new Notification();
 | 
							delete_user_notifications_other_post(userID, $postID);
 | 
				
			||||||
		$notification->set_on_elem_type(Notification::POST);
 | 
					 | 
				
			||||||
		$notification->set_on_elem_id($postID);
 | 
					 | 
				
			||||||
		$notification->set_dest_user_id(userID);
 | 
					 | 
				
			||||||
		components()->notifications->delete($notification);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Success
 | 
							//Success
 | 
				
			||||||
		return array(
 | 
							return array(
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								helpers/notifications.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								helpers/notifications.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Notifications helper
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @author Pierre HUBERT
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Delete all the notifications related to a post targeting a user
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @param int $userID Target user ID
 | 
				
			||||||
 | 
					 * @param int $postID Target post
 | 
				
			||||||
 | 
					 * @return bool TRUE in case of success / FALSE else
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function delete_user_notifications_other_post(int $userID, int $postID) : bool {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						$notification = new Notification();
 | 
				
			||||||
 | 
						$notification->set_on_elem_type(Notification::POST);
 | 
				
			||||||
 | 
						$notification->set_on_elem_id($postID);
 | 
				
			||||||
 | 
						$notification->set_dest_user_id($userID);
 | 
				
			||||||
 | 
						return components()->notifications->delete($notification);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user