Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
better_formats
Commits
9822f4ee
Commit
9822f4ee
authored
May 31, 2009
by
dragonwize
Browse files
Fixed #477934 by dragonwize: PHP warning when no roles have certain permissions.
parent
4975a236
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
better_formats_defaults.admin.inc
better_formats_defaults.admin.inc
+9
-7
No files found.
better_formats_defaults.admin.inc
View file @
9822f4ee
...
...
@@ -102,7 +102,6 @@ function better_formats_get_role_default_fields($mode, $node_type = '') {
$per_node_type
=
variable_get
(
'better_formats_per_node_type'
,
FALSE
);
$block_admins
=
better_formats_get_roles_by_perm
(
'administer blocks'
);
if
(
$per_node_type
&&
$node_type
)
{
$type
=
$mode
.
'/'
.
$node_type
;
$types
=
$type
.
"','"
.
$mode
;
...
...
@@ -121,7 +120,6 @@ function better_formats_get_role_default_fields($mode, $node_type = '') {
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)) {
continue
;
}
...
...
@@ -185,18 +183,22 @@ function better_formats_get_formats_per_role() {
/**
* Get a list of roles that have a permission.
*
* @param $perm
* Permission string to get roles for.
* @param $reset
* Boolean to clear static cache.
* @return
* An
numeric indexed key of role IDs
.
* An
array of role IDs that have the requested permission
.
*/
function
better_formats_get_roles_by_perm
(
$perm
)
{
function
better_formats_get_roles_by_perm
(
$perm
,
$reset
=
FALSE
)
{
static
$roles
;
if
(
!
$roles
[
$perm
])
{
if
(
$reset
||
!
$roles
[
$perm
])
{
$sql
=
"SELECT rid
FROM
{
permission
}
WHERE perm LIKE '%
$perm
%'
ORDER BY rid"
;
$result
=
db_query
(
$sql
);
$roles
=
array
();
$roles
[
$perm
]
=
array
();
while
(
$row
=
db_fetch_object
(
$result
))
{
$roles
[
$perm
][]
=
$row
->
rid
;
}
...
...
@@ -207,7 +209,7 @@ function better_formats_get_roles_by_perm($perm) {
/**
* Process variables for better-defaults-admin-form.tpl.php.
*
* @param $var
iable
s
* @param $vars
* The $variables array contains the following arguments:
* - $form
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment