Commit ad864fae authored by Steven Wittens's avatar Steven Wittens
Browse files

Filter.module usability: the default format is implicitly accessible to...

Filter.module usability: the default format is implicitly accessible to everyone (prevents misconfigurations).
The role checkboxes are disabled in the admin interface for the default format.
parent 9a38369d
......@@ -195,13 +195,7 @@ function filter_admin_overview() {
foreach ($roles as $rid => $name) {
$checked = strstr($format->roles, ",$rid,");
if ($default && !$checked && !$error) {
form_set_error("roles][$id][$rid", t('The default input format must be accessible to every role.'));
$error = true;
}
$row[] = form_checkbox('', "roles][$id][$rid", 1, $checked);
$row[] = form_checkbox('', "roles][$id][$rid", 1, $default || $checked, NULL, $default ? array('disabled' => 'disabled') : NULL);
}
$row[] = l('configure', 'admin/filters/'. $id);
......@@ -485,7 +479,8 @@ function filter_formats() {
$where[] = "roles LIKE '%%,%d,%%'";
$query[] = $rid;
}
$query[0] .= ' WHERE '. implode(' OR ', $where);
$query[0] .= ' WHERE '. implode(' OR ', $where) . ' OR format = %d';
$query[] = variable_get('filter_default_format', 1);
}
$result = call_user_func_array('db_query', $query);
......@@ -656,7 +651,7 @@ function filter_form($name, $value = FILTER_FORMAT_DEFAULT) {
* Returns true if the user is allowed to access this format.
*/
function filter_access($format) {
if (user_access('administer filters')) {
if (user_access('administer filters') || ($format == variable_get('filter_default_format', 1))) {
return true;
}
else {
......
......@@ -195,13 +195,7 @@ function filter_admin_overview() {
foreach ($roles as $rid => $name) {
$checked = strstr($format->roles, ",$rid,");
if ($default && !$checked && !$error) {
form_set_error("roles][$id][$rid", t('The default input format must be accessible to every role.'));
$error = true;
}
$row[] = form_checkbox('', "roles][$id][$rid", 1, $checked);
$row[] = form_checkbox('', "roles][$id][$rid", 1, $default || $checked, NULL, $default ? array('disabled' => 'disabled') : NULL);
}
$row[] = l('configure', 'admin/filters/'. $id);
......@@ -485,7 +479,8 @@ function filter_formats() {
$where[] = "roles LIKE '%%,%d,%%'";
$query[] = $rid;
}
$query[0] .= ' WHERE '. implode(' OR ', $where);
$query[0] .= ' WHERE '. implode(' OR ', $where) . ' OR format = %d';
$query[] = variable_get('filter_default_format', 1);
}
$result = call_user_func_array('db_query', $query);
......@@ -656,7 +651,7 @@ function filter_form($name, $value = FILTER_FORMAT_DEFAULT) {
* Returns true if the user is allowed to access this format.
*/
function filter_access($format) {
if (user_access('administer filters')) {
if (user_access('administer filters') || ($format == variable_get('filter_default_format', 1))) {
return true;
}
else {
......
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