mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Can cancel a membership request.
This commit is contained in:
		@@ -214,6 +214,22 @@ class GroupsComponent {
 | 
			
		||||
			array($groupID, $userID)) > 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Delete a user membership with a precise status
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param int $userID Target user ID
 | 
			
		||||
	 * @param int $groupID Target group
 | 
			
		||||
	 * @param int $status The status of the membership to delete
 | 
			
		||||
	 * @return bool TRUE for a success / FALSE else
 | 
			
		||||
	 */
 | 
			
		||||
	private function deleteMembershipWithStatus(int $userID, int $groupID, int $status) : bool {
 | 
			
		||||
		return db()->deleteEntry(
 | 
			
		||||
			self::GROUPS_MEMBERS_TABLE,
 | 
			
		||||
			"groups_id = ? AND user_id = ? AND level = ?",
 | 
			
		||||
			array($groupID, $userID, $status)
 | 
			
		||||
		);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Check whether a user received an invitation or not
 | 
			
		||||
	 * 
 | 
			
		||||
@@ -255,11 +271,18 @@ class GroupsComponent {
 | 
			
		||||
	 * @return bool TRUE for a success / FALSE else
 | 
			
		||||
	 */
 | 
			
		||||
	public function deleteInvitation(int $userID, int $groupID) : bool {
 | 
			
		||||
		return db()->deleteEntry(
 | 
			
		||||
			self::GROUPS_MEMBERS_TABLE,
 | 
			
		||||
			"groups_id = ? AND user_id = ? AND level = ?",
 | 
			
		||||
			array($groupID, $userID, GroupMember::INVITED)
 | 
			
		||||
		);
 | 
			
		||||
		return $this->deleteMembershipWithStatus($userID, $groupID, GroupMember::INVITED);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Cancel a membership request
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param int $userID The ID of the target user
 | 
			
		||||
	 * @param int $groupID The ID of the related group
 | 
			
		||||
	 * @return bool TRUE for a success / FALSE else
 | 
			
		||||
	 */
 | 
			
		||||
	public function cancelRequest(int $userID, int $groupID) : bool {
 | 
			
		||||
		return $this->deleteMembershipWithStatus($userID, $groupID, GroupMember::PENDING);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user