Can update group logo

This commit is contained in:
Pierre HUBERT
2018-07-04 13:52:39 +02:00
parent b591f008a4
commit 1b9d9a2f3e
3 changed files with 95 additions and 14 deletions

View File

@ -229,6 +229,34 @@ class GroupsComponent {
array($id));
}
/**
* Delete current group logo (if any)
*
* @param int $id The ID of the target group
* @return bool TRUE if the logo was deleted / FALSE else
*/
public function deleteLogo(int $id) : bool {
//Get the current settings of the group
$settings = $this->get_settings($id);
//Check if the group has currently an group logo or not
if($settings->has_logo()){
//Delete the previous logo
if(file_exists($settings->get_logo_sys_path()))
if(!unlink($settings->get_logo_sys_path()))
return FALSE;
//Save new information
$settings->set_logo("");
return $this->set_settings($settings);
}
//Success (nothing to be done)
return TRUE;
}
/**
* Turn a database entry into a GroupInfo object
*
@ -246,6 +274,9 @@ class GroupsComponent {
$info->set_number_members($this->countMembers($info->get_id()));
$info->set_membership_level($this->getMembershipLevel(userID, $info->get_id()));
if($data["path_logo"] != null && $data["path_logo"] != "")
$info->set_logo($data["path_logo"]);
return $info;
}
@ -298,7 +329,11 @@ class GroupsComponent {
private function GroupSettingsToDB(GroupSettings $settings) : array {
$data = array();
$data["name"] = $settings->get_name();
if($settings->has_name())
$data["name"] = $settings->get_name();
if($settings->has_logo())
$data["path_logo"] = $settings->get_logo();
return $data;
}