';
beginChairSession();
printHeader("Privacy Settings", 1);
$OC_configVars = array('OC_privacy_display', 'OC_privacy_link', 'OC_privacy_banner_options');
$OC_privacyDisplayOptionsAR = array(
0 => 'none',
1 => 'menu',
2 => 'page footer'
);
function ef($fsf, $ochsf) {
if (preg_match("/(,?)" . $fsf . "(,?)/", $ochsf, $efmatches)) {
if (($efmatches[1] == ',') && ($efmatches[2] == ',')) {
$efreplace = ',';
} else {
$efreplace = '';
}
$ochsf = preg_replace("/,?" . $fsf . ",?/", $efreplace, $ochsf);
}
return($ochsf);
}
$oc_bannerAR = json_decode($OC_configAR['OC_privacy_banner_options'], true) or err('Invalid banner options setting');
if (isset($_POST['submit']) && ($_POST['submit'] == 'Save Settings')) {
// Check for valid submission
if (!validToken('chair')) {
warn('Invalid submission');
}
$err = array();
// Check input
if (!preg_match("/^[01]$/", $_POST['OC_privacy_banner_display'])) {
$err[] = 'Banner Display option invalid';
}
if (!isset($_POST['OC_privacy_display']) || !isset($OC_privacyDisplayOptionsAR[$_POST['OC_privacy_display']])) {
$err[] = 'Policy Link Display invalid';
}
if (isset($_POST['OC_privacy_display']) && (oc_strlen($_POST['OC_privacy_display']) > 250)) {
$err[] = 'Policy Web Address too long';
}
if (!empty($err)) {
print '
Please re-enter your settings, noting the following:
- ' . implode('
- ', $err) . '
';
} else {
// Update bannerAR
$oc_bannerAR['display'] = $_POST['OC_privacy_banner_display'];
$oc_bannerAR['message'] = $_POST['OC_privacy_banner_message'];
$oc_bannerAR['dismiss'] = $_POST['OC_privacy_banner_dismiss'];
$_POST['OC_privacy_banner_options'] = json_encode($oc_bannerAR);
// Update config
updateAllConfigSettings($OC_configVars, $_POST, 'OC');
// Update Template
if ( ! ocsql_query("UPDATE `" . OCC_TABLE_TEMPLATE . "` SET `subject`='', `body`='" . safeSQLstr(varValue('OC_privacy_policy', $_POST)) . "', `updated`='" . safeSQLstr(date("Y-m-d")) . "' WHERE `templateid`='privacy_policy' AND `type`='other' LIMIT 1") ) {
warn('Failed to save privacy policy');
}
// Update consent form fields if necessary
if (OCC_LICENSE == 'Public') {
if (($_POST['OC_privacy_display'] == 0)) {
if ( ! preg_match("/fs_consent:consent/", $OC_configAR['OC_hideSubFields']) ) {
ocsql_query("UPDATE `" . OCC_TABLE_CONFIG . "` SET `value`=CONCAT(`value`, ',fs_consent:consent') WHERE `module`='OC' AND `setting`='OC_hideSubFields' LIMIT 1");
}
if ( ! preg_match("/fs_consent:consent/", $OC_configAR['OC_hideCmtFields']) ) {
ocsql_query("UPDATE `" . OCC_TABLE_CONFIG . "` SET `value`=CONCAT(`value`, ',fs_consent:consent') WHERE `module`='OC' AND `setting`='OC_hideCmtFields' LIMIT 1");
}
} else {
if (preg_match("/fs_consent:consent/", $OC_configAR['OC_hideSubFields'])) {
ocsql_query("UPDATE `" . OCC_TABLE_CONFIG . "` SET `value`='" . safeSQLstr(ef('fs_consent:consent', $OC_configAR['OC_hideSubFields'])) . "' WHERE `module`='OC' AND `setting`='OC_hideSubFields' LIMIT 1");
}
if (preg_match("/fs_consent:consent/", $OC_configAR['OC_hideCmtFields'])) {
ocsql_query("UPDATE `" . OCC_TABLE_CONFIG . "` SET `value`='" . safeSQLstr(ef('fs_consent:consent', $OC_configAR['OC_hideCmtFields'])) . "' WHERE `module`='OC' AND `setting`='OC_hideCmtFields' LIMIT 1");
}
}
}
// notify user
print 'Settings Saved
';
}
$OC_privacy_policy = $_POST['OC_privacy_policy'];
} else {
// retrieve policy template
list($none, $OC_privacy_policy) = oc_getTemplate('privacy_policy');
}
print '
';
oc_replaceCKEditor(array('OC_privacy_policy'), true, 600, 400);
printFooter();
?>