Oh yeah...and I already tested this out and it works great. I went into /manager/processors/save_settings.processor.php and changed line 7 from:
foreach ($_POST as $k => $v) {
$sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) VALUES('".mysql_escape_string($k)."', '".mysql_escape_string($v)."')";
if(!@$rs = mysql_query($sql)) {
echo "Failed to update setting value!";
exit;
}
}
to the following:
foreach ($_POST as $k => $v) {
$v = is_array($v) ? implode(",", $v) : $v;
$sql = "REPLACE INTO ".$modx->getFullTableName("system_settings")." (setting_name, setting_value) VALUES('".mysql_escape_string($k)."', '".mysql_escape_string($v)."')";
if(!@$rs = mysql_query($sql)) {
echo "Failed to update setting value!";
exit;
}
}
This works great an insures that any array is stored as a string. However, without it, I’m not sure how the plugin could pass off the $v variable since this is a loop. Perhaps the change I made could be worked into the core? This certainly would help alot with saving arrays into the site settings, not to mention giving us another way to handle site setting in various plugins.
However, I’m not sure if we want to use a simple comma in the implode...or would we prefer a different character? Then there’s the question of whether we want to allow for multi-dimensional arrays. Hmm...brings up some thoughts huh! LOL!