Commit 9de25c78 authored by dragonwize's avatar dragonwize
Browse files

Only show roles that have admininster blocks permission for block defaults.

parent 0cd4501e
...@@ -74,7 +74,7 @@ function better_formats_install() { ...@@ -74,7 +74,7 @@ function better_formats_install() {
foreach ($roles as $rid => $role) { foreach ($roles as $rid => $role) {
db_query($sql, $rid, 'node', 0, 1, 0); db_query($sql, $rid, 'node', 0, 1, 0);
db_query($sql, $rid, 'comment', 0, 1, 0); db_query($sql, $rid, 'comment', 0, 1, 0);
db_query($sql, $rid, 'block', 0, 1, 0); db_query($sql, $rid, 'block', 0, 1, 25);
} }
// Set default perms to be like core defaults. // Set default perms to be like core defaults.
...@@ -115,3 +115,21 @@ function better_formats_uninstall() { ...@@ -115,3 +115,21 @@ function better_formats_uninstall() {
WHERE name LIKE 'better_formats%'"; WHERE name LIKE 'better_formats%'";
db_query($sql); db_query($sql);
} }
/**
* Update from 1.0 to 1.1.
*/
function better_formats_update_6110() {
$ret = array();
// Insert block format defaults.
$roles = user_roles();
$sql = "INSERT INTO {better_formats_defaults}
VALUES (%d, '%s', %d, %d, %d)";
foreach ($roles as $rid => $role) {
$result = db_query($sql, $rid, 'block', 0, 1, 25);
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
}
return $ret;
}
...@@ -102,6 +102,7 @@ function better_formats_get_role_default_fields($mode, $node_type = '') { ...@@ -102,6 +102,7 @@ function better_formats_get_role_default_fields($mode, $node_type = '') {
$per_node_type = variable_get('better_formats_per_node_type', FALSE); $per_node_type = variable_get('better_formats_per_node_type', FALSE);
$block_admins = better_formats_get_roles_by_perm('administer blocks'); $block_admins = better_formats_get_roles_by_perm('administer blocks');
if ($per_node_type && $node_type) { if ($per_node_type && $node_type) {
$type = $mode . '/' . $node_type; $type = $mode . '/' . $node_type;
$types = $type . "','" . $mode; $types = $type . "','" . $mode;
...@@ -120,6 +121,7 @@ function better_formats_get_role_default_fields($mode, $node_type = '') { ...@@ -120,6 +121,7 @@ function better_formats_get_role_default_fields($mode, $node_type = '') {
while ($role = db_fetch_object($result)) { while ($role = db_fetch_object($result)) {
if (in_array($role->rid, $roles_set) || ($mode === 'block' && !in_array($role->rid, $block_admins))) { if (in_array($role->rid, $roles_set) || ($mode === 'block' && !in_array($role->rid, $block_admins))) {
// if (in_array($role->rid, $roles_set)) {
continue; continue;
} }
......
Supports Markdown
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