first part of plugin setting

This commit is contained in:
Haitem
2020-12-09 14:30:41 +01:00
parent 42443c8b58
commit ee0ebff76a
3 changed files with 40 additions and 11 deletions

View File

@@ -4,20 +4,20 @@ class SettingsManager{
return Db::loadAll ("SELECT * FROM settings");
}
static function getByName($settingName, $group = '') {
if ($group != '') return Db::loadOne("SELECT * FROM settings WHERE name = ? AND group = ?", array($settingName, $group));
static function getByName($settingName, $type = '') {
if ($type != '') return Db::loadOne("SELECT * FROM settings WHERE name = ? AND type = ?", array($settingName, $type));
return Db::loadOne("SELECT * FROM settings WHERE name = ?", array($settingName));
}
static function getSettingGroup($group) {
return Db::loadAll("SELECT * FROM settings WHERE group = ?", array($group));
static function getSettingGroup($type) {
return Db::loadAll("SELECT * FROM settings WHERE type=?", array($type));
}
public static function create ($name, $value, $group = '') {
public static function create ($name, $value, $type = '') {
$setting = array (
'name' => $name,
'value' => $value,
'group' => $group,
'type' => $type,
);
try {
Db::add ('settings', $setting);
@@ -27,9 +27,9 @@ class SettingsManager{
}
}
public static function update ($name, $value, $group = '') {
if ($this.getByName($name)){
$this->create($name, $value, $group);
public static function update ($name, $value, $type = '') {
if (self::getByName($name)){
self::create($name, $value, $type);
} else {
try {
Db::edit ('settings', [