mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Can delete groups.
This commit is contained in:
		@@ -684,6 +684,38 @@ class GroupsComponent {
 | 
			
		||||
			array($groupID, $userID));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Delete a group
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param int $groupID Target group id
 | 
			
		||||
	 * @return bool TRUE for a success / FALSE else
 | 
			
		||||
	 */
 | 
			
		||||
	public function delete_group(int $groupID) : bool {
 | 
			
		||||
 | 
			
		||||
		//Delete group image
 | 
			
		||||
		if(!$this->deleteLogo($groupID))
 | 
			
		||||
			return FALSE;
 | 
			
		||||
 | 
			
		||||
		//Delete all group posts
 | 
			
		||||
		if(!components()->posts->deleteAllGroup($groupID))
 | 
			
		||||
			return FALSE;
 | 
			
		||||
 | 
			
		||||
		//Delete all group related notifications
 | 
			
		||||
		if(!components()->notifications->deleteAllRelatedWithGroup($groupID))
 | 
			
		||||
		 	return FALSE;
 | 
			
		||||
 | 
			
		||||
		//Delete all group members
 | 
			
		||||
		if(!db()->deleteEntry(self::GROUPS_MEMBERS_TABLE, "groups_id = ?", array($groupID)))
 | 
			
		||||
			return FALSE;
 | 
			
		||||
 | 
			
		||||
		//Delete group information
 | 
			
		||||
		if(!db()->deleteEntry(self::GROUPS_LIST_TABLE, "id = ?", array($groupID)))
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		
 | 
			
		||||
		//Success
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Turn a database entry into a GroupInfo object
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user