Commit 6eb7b50d authored by Clare Lenihan's avatar Clare Lenihan
Browse files

fix for bug #1654

allow public views setting now prevents adding and using public views
parent 2b584e8e
......@@ -39,7 +39,13 @@ function pieform_element_viewacl(Pieform $form, $element) {
$value = $form->get_value($element);
// Look for the presets and split them into two groups
$presets = array('public', 'loggedin', 'friends');
$presets = array();
if (get_config('allowpublicviews') == '1') {
$presets = array('public', 'loggedin', 'friends');
}
else {
$presets = array('loggedin', 'friends');
}
if ($value) {
foreach ($value as $key => &$item) {
if (is_array($item)) {
......@@ -87,4 +93,28 @@ function pieform_render_viewacl_getvaluebytype($type, $id) {
return "$type: $id";
}
function pieform_element_viewacl_get_value(Pieform $form, $element) {
global $USER;
$values = null;
$global = ($form->get_property('method') == 'get') ? $_GET : $_POST;
if (isset($element['value'])) {
$values = $element['value'];
}
else if (isset($global[$element['name']])) {
$value = $global[$element['name']];
$values = $value;
}
else if (isset($element['defaultvalue'])) {
$values = $element['defaultvalue'];
}
if (get_config('allowpublicviews') != '1') {
foreach ($values as $key => $value) {
if ($value['type'] == 'public') {
unset($values[$key]);
}
}
}
return $values;
}
?>
......@@ -1190,6 +1190,8 @@ function can_view_view($view_id, $user_id=null) {
// check public
if (
get_config('allowpublicviews') == '1'
&&
isset($view_record['access']['public'])
&& (
$view_record['access']['public']['startdate'] == null
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment