function Settings::IsInList that tests if an option of a multi-select setting is set

This commit is contained in:
Michael Wyraz
2016-07-22 10:30:13 +02:00
parent a95233041e
commit 54e2f83b17
4 changed files with 33 additions and 16 deletions

View File

@@ -124,6 +124,23 @@ class Settings {
return $result;
}
/**
* tests if a setting-value that i s a comma separated list contains an entry
*
* @param string $setting a group and a varname separated by a dot (group.varname)
* @param string $entry the entry that is expected to be in the list
*
* @return boolean true, if the list contains $entry
*/
public function pIsInList($setting = null, $entry = null) {
$s=Settings::Get($setting);
if ($s==null) {
return false;
}
$slist = explode(",",$s);
return in_array($entry, $slist);
}
/**
* update a setting / set a new value
*