Add default settings generation on new user creation

This commit is contained in:
osaajani 2020-01-06 23:33:27 +01:00
parent 2671c464a4
commit d8839a57d0
2 changed files with 30 additions and 3 deletions

View file

@ -75,4 +75,22 @@ namespace controllers\internals;
return (bool) $this->get_model()->insert($setting);
}
/**
* Generate and insert default settings for a user
* @param int $id_user : user id
* @return bool
*/
public function create_defaults_for_user(int $id_user)
{
$all_success = true;
foreach (USER_DEFAULT_SETTINGS as $name => $value)
{
$success = $this->create($id_user, $name, $value);
$all_success = ($all_success && $success);
}
return $all_success;
}
}