Can delete groups.

This commit is contained in:
Pierre HUBERT
2018-08-31 09:56:46 +02:00
parent 9df1c93a24
commit 827fec68c7
5 changed files with 145 additions and 9 deletions

View File

@ -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
*